파비의 매일매일 공부기록

Today's Challenge 본문

Problem Solving/LeetCode

Today's Challenge

fabichoi 2022. 6. 29. 23:45

https://leetcode.com/problems/queue-reconstruction-by-height/

 

Queue Reconstruction by Height - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

그냥 대 놓고 문제에 1번 idx로 정렬하고 그다음에 0번 idx로 정렬해서 출력하면 된다고 되어 있음.

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

'Problem Solving > LeetCode' 카테고리의 다른 글

Today's Challenge  (0) 2022.07.01
Today's Challenge  (0) 2022.06.30
Today's Challenge  (0) 2022.06.28
Today's Challenge  (0) 2022.06.27
Today's Challenge  (0) 2022.06.26
Comments