Skip to content

Commit 954c7ef

Browse files
authored
Update 452-minimum-number-of-arrows-to-burst-balloons.js
1 parent fc8d841 commit 954c7ef

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

452-minimum-number-of-arrows-to-burst-balloons.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/**
2+
* @param {number[][]} points
3+
* @return {number}
4+
*/
5+
const findMinArrowShots = function(points) {
6+
const n = points.length
7+
if(n === 0) return 0
8+
points.sort((a, b) => a[1] - b[1])
9+
let res = 1
10+
let end = points[0][1]
11+
12+
for(let i = 1; i < n; i++) {
13+
if(end >= points[i][0]) continue
14+
res++
15+
end = points[i][1]
16+
}
17+
18+
return res
19+
};
20+
21+
// another
22+
123
/**
224
* @param {number[][]} points
325
* @return {number}

0 commit comments

Comments
 (0)