mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
@ -226,7 +226,25 @@ class Solution:
|
|||||||
|
|
||||||
Go:
|
Go:
|
||||||
|
|
||||||
|
Javascript:
|
||||||
|
```Javascript
|
||||||
|
var reconstructQueue = function(people) {
|
||||||
|
let queue = []
|
||||||
|
people.sort((a, b ) => {
|
||||||
|
if(b[0] !== a[0]) {
|
||||||
|
return b[0] - a[0]
|
||||||
|
} else {
|
||||||
|
return a[1] - b[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
for(let i = 0; i < people.length; i++) {
|
||||||
|
queue.splice(people[i][1], 0, people[i])
|
||||||
|
}
|
||||||
|
return queue
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
-----------------------
|
-----------------------
|
||||||
|
@ -175,7 +175,24 @@ class Solution:
|
|||||||
|
|
||||||
Go:
|
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
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
-----------------------
|
-----------------------
|
||||||
|
Reference in New Issue
Block a user