Skip to content

Commit e83c9ab

Browse files
authored
Create 1760-minimum-limit-of-balls-in-a-bag.js
1 parent 467eb78 commit e83c9ab

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @param {number[]} nums
3+
* @param {number} maxOperations
4+
* @return {number}
5+
*/
6+
const minimumSize = function(nums, maxOperations) {
7+
let L = 1, R = 10 ** 9;
8+
while(L < R){
9+
let M = (L + (R - L) / 2) >> 0, cnt = 0;
10+
for(let x of nums) cnt += ((x + M - 1) / M - 1) >> 0;
11+
if(cnt > maxOperations) L = M + 1;
12+
else R = M;
13+
}
14+
return L;
15+
};
16+

0 commit comments

Comments
 (0)