From b05f66d853a42afa17bb98963c2fdf65c3bcd6a8 Mon Sep 17 00:00:00 2001 From: eeee0717 Date: Thu, 4 Jan 2024 10:41:09 +0800 Subject: [PATCH] =?UTF-8?q?Update0406.=E6=A0=B9=E6=8D=AE=E5=AE=A1=E7=A8=BF?= =?UTF-8?q?=E9=87=8D=E5=BB=BA=E9=98=9F=E5=88=97=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?C#?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0406.根据身高重建队列.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/problems/0406.根据身高重建队列.md b/problems/0406.根据身高重建队列.md index 9cd78fac..b0b02c14 100644 --- a/problems/0406.根据身高重建队列.md +++ b/problems/0406.根据身高重建队列.md @@ -396,6 +396,29 @@ object Solution { } } ``` +### C# +```csharp +public class Solution +{ + public int[][] ReconstructQueue(int[][] people) + { + Array.Sort(people, (a, b) => + { + if (a[0] == b[0]) + { + return a[1] - b[1]; + } + return b[0] - a[0]; + }); + var res = new List(); + for (int i = 0; i < people.Length; i++) + { + res.Insert(people[i][1], people[i]); + } + return res.ToArray(); + } +} +```