일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- concurrency
- Regular Expression
- DWG
- 315. Count of Smaller Numbers After Self
- 밴픽
- 시바견
- 운영체제
- Substring with Concatenation of All Words
- 715. Range Module
- shiba
- data science
- 컴퓨터의 구조
- attribute
- Class
- Python
- Generator
- 프로그래머스
- 30. Substring with Concatenation of All Words
- t1
- Convert Sorted List to Binary Search Tree
- Python Code
- Decorator
- 43. Multiply Strings
- iterator
- 109. Convert Sorted List to Binary Search Tree
- kaggle
- Protocol
- Python Implementation
- LeetCode
- 파이썬
Archives
- Today
- Total
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' 카테고리의 다른 글
프로그래머스: 소수 찾기 (0) | 2021.10.19 |
---|---|
프로그래머스: H-Index (0) | 2021.10.18 |
프로그래머스: 디스크 컨트롤러 (0) | 2021.10.16 |
프로그래머스: 더 맵게 (0) | 2021.10.16 |
프로그래머스: 주식 가격 (0) | 2021.10.16 |