Skip to content

Commit ab14fe3

Browse files
authored
Update 452-minimum-number-of-arrows-to-burst-balloons.js
1 parent 63f0bf1 commit ab14fe3

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

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

+8-9
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ const findMinArrowShots = function(points) {
2626
const findMinArrowShots = function(points) {
2727
if(points == null || points.length === 0) return 0
2828
points.sort((a, b) => a[1] - b[1])
29-
let ans = 1
30-
let lastX = points[0][1]
31-
for (let i = 1; i < points.length; i++) {
32-
if(points[i][0] <= lastX) continue
33-
ans++
34-
lastX = points[i][1]
29+
let end = points[0][1], res = 1
30+
for(let i = 1, len = points.length; i < len; i++) {
31+
if(points[i][0] > end) {
32+
end = points[i][1]
33+
res++
34+
}
3535
}
36-
return ans
37-
}
38-
36+
return res
37+
};

0 commit comments

Comments
 (0)