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

LeetCode406. 根据身高重建队列

    • 题目链接
    • 代码

题目链接

https://leetcode.cn/problems/queue-reconstruction-by-height/LeetCode(力扣)406. 根据身高重建队列Python_第1张图片

代码

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

你可能感兴趣的:(leetcode,算法,职场和发展)