분류 전체보기(221)
-
[LeetCode] Evaluate Reverse Polish Notation (Python)
import math class Solution: def evalRPN(self, tokens: List[str]) -> int: operation = ["+", "-", "*", "/"] stack = [] if len(tokens) == 1: return int(tokens[0]) for i in range(len(tokens)): if tokens[i] not in operation: stack.append(int(tokens[i])) else: num1 = stack.pop() num2 = stack.pop() new_num = 0 if tokens[i] == "+": new_num = num2 + num1 elif tokens[i] == "-": new_num = num2 - num1 elif ..
2024.03.06 -
[LeetCode] Daily Temperatures (Python)
보호되어 있는 글입니다.
2024.03.06 -
[LeetCode] Valid Parentheses (Python)
class Solution: def isValid(self, s: str) -> bool: stack=[] brackets={'}':'{',')':'(',']':'['} for bracket in s: if bracket in brackets.values(): stack.append(bracket) else: if stack and brackets[bracket]==stack[-1] : stack.pop() else: return False if stack: return False return True
2024.03.06 -
[LeetCode] Min Stack (Python)
보호되어 있는 글입니다.
2024.03.06 -
[백준 13458] 시험감독 (Python)
N = int(input()) A = list(map(int, input().split())) B, C = map(int, input().split()) answer = 0 for i in range(len(A)): if A[i]
2024.03.05 -
[LeetCode] Perfect Squares (Python)
보호되어 있는 글입니다.
2024.03.05