Skip to content

Commit a6fcef4

Browse files
committed
92 :
1 parent f4c2975 commit a6fcef4

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

Day92/index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @param {number[]} people
3+
* @param {number} limit
4+
* @return {number}
5+
*/
6+
var numRescueBoats = function (people, limit) {
7+
8+
people.sort((a, b) => a - b)
9+
10+
let left = 0;
11+
let right = people.length - 1;
12+
let res = 0
13+
14+
while (left <= right) {
15+
res++
16+
if (people[left] + people[right] <= limit) {
17+
left++
18+
right--
19+
} else {
20+
21+
right--
22+
}
23+
}
24+
25+
return res
26+
};

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,6 @@ If you are loving solving problems in leetcode, please contact me to enjoy it to
202202

203203
|Day 90| [42. Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water/) | [javascript]()|[:memo:](https://leetcode.com/problems/trapping-rain-water/)|Hard|
204204

205-
|Day 91| [1296. Divide Array in Sets of K Consecutive Numbers](https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/) | [javascript]()|[:memo:](https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/)|Medium|
205+
|Day 91| [1296. Divide Array in Sets of K Consecutive Numbers](https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/) | [javascript]()|[:memo:](https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/)|Medium|
206+
207+
|Day 92| [881. Boats to Save People](https://leetcode.com/problems/boats-to-save-people/) | [javascript]()|[:memo:](https://leetcode.com/problems/boats-to-save-people/)|Medium|

0 commit comments

Comments
 (0)