-
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy path406.py
23 lines (20 loc) · 914 Bytes
/
406.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
__________________________________________________________________________________________________
sample 96 ms submission
class Solution:
def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:
people.sort(key=lambda p: (-p[0], p[1]))
queue = []
for person in people:
queue.insert(person[1], person)
return queue
__________________________________________________________________________________________________
sample 13332 kb submission
from collections import deque
class Solution:
def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:
order = deque()
people.sort(key = lambda x: (-x[0], x[1]))
for pair in people:
order.insert(pair[1], pair)
return list(order)
__________________________________________________________________________________________________