일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
Tags
- 밴픽
- 715. Range Module
- Convert Sorted List to Binary Search Tree
- 43. Multiply Strings
- LeetCode
- 파이썬
- 315. Count of Smaller Numbers After Self
- t1
- iterator
- 시바견
- Generator
- Protocol
- 109. Convert Sorted List to Binary Search Tree
- 30. Substring with Concatenation of All Words
- Python Code
- Class
- DWG
- attribute
- Substring with Concatenation of All Words
- 운영체제
- kaggle
- concurrency
- 프로그래머스
- shiba
- Python
- Decorator
- Python Implementation
- data science
- 컴퓨터의 구조
- Regular Expression
Archives
- Today
- Total
목록239. Sliding Window Maximum (1)
Scribbling
LeetCode: 239. Sliding Window Maximum
가장 먼저 떠오른 방법은 Priority Queue를 사용하는 것. Time Complexity: O(N*logN) import heapq class PriorityQueue: def __init__(self): self.pq = [] self.removals = [] def insert(self, elem): heapq.heappush(self.pq, -elem) def gettop(self): return -self.pq[0] def remove(self, elem): if elem == -self.pq[0]: heapq.heappop(self.pq) while self.removals and self.pq[0] == self.removals[0]: heapq.heappop(self.pq) heapq..
Computer Science/Coding Test
2021. 12. 23. 09:34