forked from onlybooks/python-algorithm-interview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path79-1.py
More file actions
17 lines (14 loc) · 481 Bytes
/
79-1.py
File metadata and controls
17 lines (14 loc) · 481 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import heapq
from typing import List
class Solution:
def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:
heap = []
# 키 역순, 인덱스 삽입
for person in people:
heapq.heappush(heap, (-person[0], person[1]))
result = []
# 키 역순, 인덱스 추출
while heap:
person = heapq.heappop(heap)
result.insert(person[1], [-person[0], person[1]])
return result