From 1f813d446f9d8a3710576f579200114f75e2ee8a Mon Sep 17 00:00:00 2001 From: Jijie LIU Date: Tue, 22 Jun 2021 17:22:42 +0200 Subject: [PATCH] =?UTF-8?q?update=20406=20=E6=A0=B9=E6=8D=AE=E8=BA=AB?= =?UTF-8?q?=E9=AB=98=E9=87=8D=E5=BB=BA=E9=98=9F=E5=88=97:=20=E7=A7=BB?= =?UTF-8?q?=E9=99=A4Pyhton=E7=89=88=E6=9C=AC=E7=9A=84=E5=86=97=E4=BD=99?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0406.根据身高重建队列.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/problems/0406.根据身高重建队列.md b/problems/0406.根据身高重建队列.md index 9aca5b94..946c41ce 100644 --- a/problems/0406.根据身高重建队列.md +++ b/problems/0406.根据身高重建队列.md @@ -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 ```