406. Queue Reconstruction by Height
Input:
[[7,0], [4,4], [7,1], [5,0], [6,1], [5,2]]
Output:
[[5,0], [7,0], [5,2], [6,1], [4,4], [7,1]]class Solution(object):
def reconstructQueue(self, people):
"""
:type people: List[List[int]]
:rtype: List[List[int]]
"""
people.sort(key = lambda x: [-x[0], x[1]])
result = []
for [h, k] in people:
result.insert(k, [h,k])
return resultLast updated
Was this helpful?