LC 0406 [M] Queue Reconstruction by Height - ALawliet/algorithms GitHub Wiki

[7,0],[4,4],[7,1],[5,0],[6,1],[5,2](/ALawliet/algorithms/wiki/7,0],[4,4],[7,1],[5,0],[6,1],[5,2)

[7, 0], [7, 1], [6, 1], [5, 0], [5, 2], [4, 4](/ALawliet/algorithms/wiki/7,-0],-[7,-1],-[6,-1],-[5,-0],-[5,-2],-[4,-4)

[7, 0](/ALawliet/algorithms/wiki/7,-0)
[7, 0], [7, 1](/ALawliet/algorithms/wiki/7,-0],-[7,-1)
[7, 0], [6, 1], [7, 1](/ALawliet/algorithms/wiki/7,-0],-[6,-1],-[7,-1)
[5, 0], [7, 0], [6, 1], [7, 1](/ALawliet/algorithms/wiki/5,-0],-[7,-0],-[6,-1],-[7,-1)
[5, 0], [7, 0], [5, 2], [6, 1], [7, 1](/ALawliet/algorithms/wiki/5,-0],-[7,-0],-[5,-2],-[6,-1],-[7,-1)
[5, 0], [7, 0], [5, 2], [6, 1], [4, 4], [7, 1](/ALawliet/algorithms/wiki/5,-0],-[7,-0],-[5,-2],-[6,-1],-[4,-4],-[7,-1)
class Solution:
    def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:
        people.sort(key=lambda height_front: [-height_front[0], height_front[1]]) # sort by -height (desc) then +front (asc)
        print(people)
        Q = []
        for p in people:
            height, front = p
            Q.insert(front, p)
        return Q