일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 시바견
- DWG
- 715. Range Module
- Substring with Concatenation of All Words
- Python Implementation
- concurrency
- Generator
- 밴픽
- kaggle
- 43. Multiply Strings
- Python Code
- Python
- data science
- 30. Substring with Concatenation of All Words
- Decorator
- Class
- iterator
- shiba
- attribute
- 컴퓨터의 구조
- 315. Count of Smaller Numbers After Self
- 운영체제
- Convert Sorted List to Binary Search Tree
- t1
- Protocol
- LeetCode
- 프로그래머스
- 파이썬
- Regular Expression
- 109. Convert Sorted List to Binary Search Tree
Archives
- Today
- Total
Scribbling
LeetCode: 155. Min Stack 본문
class MinStack:
def __init__(self):
self.stack = []
def push(self, val: int) -> None:
if not self.stack:
self.stack.append([val, val])
else:
self.stack.append([val, min(val, self.stack[-1][1])])
def pop(self) -> None:
self.stack.pop()
def top(self) -> int:
return self.stack[-1][0]
def getMin(self) -> int:
return self.stack[-1][1]
# Your MinStack object will be instantiated and called as such:
# obj = MinStack()
# obj.push(val)
# obj.pop()
# param_3 = obj.top()
# param_4 = obj.getMin()
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 160. Intersection of Two Linked Lists (0) | 2021.12.02 |
---|---|
LeetCode: 162. Find Peak Element (0) | 2021.12.01 |
LeetCode: 152. Maximum Product Subarray (0) | 2021.11.29 |
LeetCode: 134. Gas Station (0) | 2021.11.26 |
LeetCode: 150. Evaluate Reverse Polish Notation (0) | 2021.11.26 |