2018-11-29 leetcode Queue Reconstruction by Height Queue Reconstruction by HeightSort Insert Version - 84ms 123456789101112131415class Solution(object): def reconstructQueue(self, people): """ :type people: List[List[int]] :rtype: List[List[int]] """ if not people: return [] n = len(people) people_sorted = sorted(people, key = lambda x: (-x[0],x[1])) res = [people_sorted[0]] for i in range(1,n): hi, ki = people_sorted[i] res.insert(ki, people_sorted[i]) return res test code 1234In [161]: people = [[7,0],[4,4],[7,1],[5,0],[6,1],[5,2]]In [162]: s = Solution(); t = s.reconstructQueue(people); print(t)[[5, 0], [7, 0], [5, 2], [6, 1], [4, 4], [7, 1]] leet code Newer Palindromic Substrings Older Counting Bits