Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:
- ps = sorted(people, key=lambda p: (-p[0],p[1]))
- ans = []
- for p in ps:
- num_b = 0
- idx = 0
- for i in range(len(ans)):
- idx = i
- if p[1] == num_b:
- break
- if p[0] <= ans[i][0]:
- num_b += 1
- else:
- idx = len(ans)
- ans.insert(idx, p)
- return ans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement