class Solution(object):
def reconstructQueue(self, people):
"""
:type people: List[List[int]]
:rtype: List[List[int]]
"""
sortOfpeople = sorted(people, key = lambda x:(-x[0],x[1]))
res = []
for x in sortOfpeople:
res.insert(x[1],x)
return res
- 思路:身高从高到低排列,然后使用insert()函数挨个插入。