File tree Expand file tree Collapse file tree 1 file changed +1
-55
lines changed
Solution/452. Minimum Number of Arrows to Burst Balloons Expand file tree Collapse file tree 1 file changed +1
-55
lines changed Original file line number Diff line number Diff line change 11---
22comments : true
33difficulty : Medium
4- edit_url : https://github.com/doocs/leetcode/edit/main/solution/0400-0499/0452.Minimum%20Number%20of%20Arrows%20to%20Burst%20Balloons/README_EN.md
4+ edit_url : Antim
55tags :
66 - Greedy
77 - Array
1212
1313# [ 452. Minimum Number of Arrows to Burst Balloons] ( https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons )
1414
15- [ 中文文档] ( /solution/0400-0499/0452.Minimum%20Number%20of%20Arrows%20to%20Burst%20Balloons/README.md )
16-
1715## Description
1816
1917<!-- description:start -->
@@ -129,58 +127,6 @@ public:
129127};
130128```
131129
132- #### Go
133-
134- ```go
135- func findMinArrowShots(points [][]int) (ans int) {
136- sort.Slice(points, func(i, j int) bool { return points[i][1] < points[j][1] })
137- last := -(1 << 60)
138- for _, p := range points {
139- a, b := p[0], p[1]
140- if a > last {
141- ans++
142- last = b
143- }
144- }
145- return
146- }
147- ```
148-
149- #### TypeScript
150-
151- ``` ts
152- function findMinArrowShots(points : number [][]): number {
153- points .sort ((a , b ) => a [1 ] - b [1 ]);
154- let ans = 0 ;
155- let last = - Infinity ;
156- for (const [a, b] of points ) {
157- if (last < a ) {
158- ans ++ ;
159- last = b ;
160- }
161- }
162- return ans ;
163- }
164- ```
165-
166- #### C#
167-
168- ``` cs
169- public class Solution {
170- public int FindMinArrowShots (int [][] points ) {
171- Array .Sort (points , (a , b ) => a [1 ] < b [1 ] ? - 1 : a [1 ] > b [1 ] ? 1 : 0 );
172- int ans = 0 ;
173- long last = long .MinValue ;
174- foreach (var point in points ) {
175- if (point [0 ] > last ) {
176- ++ ans ;
177- last = point [1 ];
178- }
179- }
180- return ans ;
181- }
182- }
183- ```
184130
185131<!-- tabs:end -->
186132
You can’t perform that action at this time.
0 commit comments