0
点赞
收藏
分享

微信扫一扫

Python | Leetcode Python题解之第406题根据身高重建队列

逸省 2024-09-17 阅读 1

题目:

题解:

class Solution:
    def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:
        people.sort(key=lambda x: (-x[0], x[1]))
        n = len(people)
        ans = list()
        for person in people:
            ans[person[1]:person[1]] = [person]
        return ans
举报

相关推荐

0 条评论