Merge pull request #431 from EnzoSeason/leetcode-406

update 406 根据身高重建队列: 移除Pyhton版本的冗余代码
This commit is contained in:
程序员Carl 2021-06-24 15:17:30 +08:00 committed by GitHub
commit e23b6a152c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 5 deletions

View File

@ -214,13 +214,10 @@ Python
```python
class Solution:
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 = []
for p in people:
if p[1] > len(que):
que.append(p)
else:
que.insert(p[1], p)
que.insert(p[1], p)
return que
```