LeetCode(力扣)406. 根据身高重建队列Python

LeetCode406. 根据身高重建队列

题目链接

https://leetcode.cn/problems/queue-reconstruction-by-height/在这里插入图片描述

代码

class Solution:
    def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:
        people.sort(key =lambda x: (-x[0], x[1]))
        que = []
        for p in people:
            que.insert(p[1], p)
        return que

猜你喜欢

转载自blog.csdn.net/qq_44953660/article/details/132889491