5 lines Python solution


  • 0
    class Solution(object):
        def reconstructQueue(self, people):
            people.sort(cmp = lambda x, y: -1 if (x[0] > y[0] or (x[0]==y[0] and x[1]<y[1])) else 1)
            res = []
            for p in people:
                res.insert(p[1],p)
            return res
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.