mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
Merge pull request #431 from EnzoSeason/leetcode-406
update 406 根据身高重建队列: 移除Pyhton版本的冗余代码
This commit is contained in:
@ -214,13 +214,10 @@ Python:
|
|||||||
```python
|
```python
|
||||||
class Solution:
|
class Solution:
|
||||||
def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:
|
def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:
|
||||||
people.sort(key=lambda x: (x[0], -x[1]), reverse=True)
|
people.sort(key=lambda x: (-x[0], x[1]))
|
||||||
que = []
|
que = []
|
||||||
for p in people:
|
for p in people:
|
||||||
if p[1] > len(que):
|
que.insert(p[1], p)
|
||||||
que.append(p)
|
|
||||||
else:
|
|
||||||
que.insert(p[1], p)
|
|
||||||
return que
|
return que
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user