From 55d676e194180cb33564a7b3019068ccd1ad834f Mon Sep 17 00:00:00 2001 From: eeee0717 Date: Fri, 5 Jan 2024 14:08:10 +0800 Subject: [PATCH] =?UTF-8?q?Update=200452.=E7=94=A8=E6=9C=80=E5=B0=91?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E7=9A=84=E7=AE=AD=E5=BC=95=E7=88=86=E6=B0=94?= =?UTF-8?q?=E7=90=83=EF=BC=8C=E6=B7=BB=E5=8A=A0C#?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0452.用最少数量的箭引爆气球.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/problems/0452.用最少数量的箭引爆气球.md b/problems/0452.用最少数量的箭引爆气球.md index 90cd7085..cd57f83b 100644 --- a/problems/0452.用最少数量的箭引爆气球.md +++ b/problems/0452.用最少数量的箭引爆气球.md @@ -332,6 +332,24 @@ object Solution { } } ``` +### C# +```csharp +public class Solution +{ + public int FindMinArrowShots(int[][] points) + { + if (points.Length == 0) return 0; + Array.Sort(points, (a, b) => a[0].CompareTo(b[0])); + int count = 1; + for (int i = 1; i < points.Length; i++) + { + if (points[i][0] > points[i - 1][1]) count++; + else points[i][1] = Math.Min(points[i][1], points[i - 1][1]); + } + return count; + } +} +```