Skip to content

Commit 9362f4d

Browse files
authored
Create 3074-apple-redistribution-into-boxes.js
1 parent 0592897 commit 9362f4d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @param {number[]} apple
3+
* @param {number[]} capacity
4+
* @return {number}
5+
*/
6+
var minimumBoxes = function(apple, capacity) {
7+
let total_apple = apple.reduce((a, b) => a + b, 0)
8+
capacity.sort((a, b) => b - a)
9+
let ans = 0
10+
let cur = 0
11+
for (let c of capacity) {
12+
cur += c
13+
ans += 1
14+
if (cur >= total_apple) {
15+
return ans
16+
}
17+
}
18+
};

0 commit comments

Comments
 (0)