Skip to content

Commit 86a93f8

Browse files
authored
Update 1739-building-boxes.js
1 parent 84724a5 commit 86a93f8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

1739-building-boxes.js

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/**
2+
* @param {number} n
3+
* @return {number}
4+
*/
5+
const minimumBoxes = function(n) {
6+
let i = 1, c = 1, s = 1
7+
while(s < n) {
8+
i += 1, c += i, s += c
9+
}
10+
while(s - i >= n) {
11+
s -= i, c -= 1, i -= 1
12+
}
13+
return c
14+
};
15+
16+
// another
17+
18+
119
/**
220
* @param {number} n
321
* @return {number}

0 commit comments

Comments
 (0)