일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Generator
- DWG
- attribute
- Python
- shiba
- Substring with Concatenation of All Words
- 43. Multiply Strings
- 프로그래머스
- Class
- 315. Count of Smaller Numbers After Self
- concurrency
- Python Implementation
- 운영체제
- Regular Expression
- 715. Range Module
- LeetCode
- 30. Substring with Concatenation of All Words
- Python Code
- Protocol
- 밴픽
- 시바견
- iterator
- t1
- kaggle
- data science
- 109. Convert Sorted List to Binary Search Tree
- Decorator
- Convert Sorted List to Binary Search Tree
- 컴퓨터의 구조
- 파이썬
Archives
- Today
- Total
목록이중 우선 순위 큐 (1)
Scribbling
프로그래머스: 이중 우선 순위 큐
import heapq def solution(operations): answer = [] h = [] for operation in operations: opt, num = operation.split(' ') if opt == 'I': heapq.heappush(h, int(num)) else: if num == '-1': if h: heapq.heappop(h) # 최대 값 삭제 else: if h: h.pop(h.index(max(h))) heapq.heapify(h) if not h: return [0, 0] else: return [max(h), h[0]] return answer
Computer Science/Coding Test
2021. 10. 16. 19:21