mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-07 07:35:35 +08:00
Update 0452.用最少数量的箭引爆气球,添加C#
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<p align="center">
|
||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||
|
Reference in New Issue
Block a user