Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- createSlice
- JavaScript
- 코딩테스트합격자되기
- 테코테코
- Get
- C++
- 이코테
- redux
- react-router
- redux-toolkit
- react
- 알고리즘
- programmers
- axios
- Algorithm
- 자바
- maeil-mail
- redux-saga
- sw expert academy
- 프로그래머스
- react-redux
- 항해99
- java
- 리액트
- SW
- useDispatch
- 매일메일
- Python
- json-server
- 항해플러스
Archives
- Today
- Total
Binary Journey
[프로그래머스] 이중우선순위큐 본문
반응형
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges
import heapq
def solution(operations):
answer = []
while operations:
o, num = operations.pop(0).split()
if o == "I":
heapq.heappush(answer, int(num))
elif answer and o == "D" and int(num) > 0:
answer.pop()
elif answer and o == "D" and int(num) < 0:
answer.pop(0)
answer.sort()
if answer:
return [answer[-1], answer[0]]
else:
return [0,0]
반응형
'프로그래머스 > level 3' 카테고리의 다른 글
[프로그래머스] 베스트 앨범 (0) | 2022.05.20 |
---|---|
[프로그래머스] 순위 (0) | 2022.04.21 |
[프로그래머스] 가장 먼 노드 (0) | 2022.04.21 |
[프로그래머스] 정수 삼각형 (0) | 2022.03.16 |
[프로그래머스] 헤비 유저가 소유한 장소 (MySQL) (0) | 2021.08.10 |