Simple Greedy Python


  • 1
    class Solution(object):
        def reconstructQueue(self, people):
            ans = []
            heap = []
            for p in people:
                heapq.heappush(heap, [-p[0], p[1]])
            while heap:
                hi = heapq.heappop(heap)
                ans.insert(hi[1], [-hi[0], hi[1]])
            return ans
    

Log in to reply
 

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