0452.用最少数量的箭引爆气球 Javascript
This commit is contained in:
parent
7beb711f0d
commit
f19cc3ddd4
|
|
@ -175,7 +175,24 @@ class Solution:
|
|||
|
||||
Go:
|
||||
|
||||
Javascript:
|
||||
```Javascript
|
||||
var findMinArrowShots = function(points) {
|
||||
points.sort((a, b) => {
|
||||
return a[0] - b[0]
|
||||
})
|
||||
let result = 1
|
||||
for(let i = 1; i < points.length; i++) {
|
||||
if(points[i][0] > points[i - 1][1]) {
|
||||
result++
|
||||
} else {
|
||||
points[i][1] = Math.min(points[i - 1][1], points[i][1])
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
-----------------------
|
||||
|
|
|
|||
Loading…
Reference in New Issue