MCPcopy Create free account
hub / github.com/Hsinha11/Leetcode-solutions / minimumBoxes

Method minimumBoxes

1739-Building-Boxes/Building-Boxes.py:2–12  ·  view source on GitHub ↗
(self, n: int)

Source from the content-addressed store, hash-verified

1class Solution:
2 def minimumBoxes(self, n: int) -> int:
3 r = 0
4 while (n_upper := r*(r+1)*(r+2)//6) < n:
5 r += 1
6 m = r*(r+1)//2
7 for i in range(r, 0, -1):
8 if (n_upper - i) < n:
9 break
10 n_upper -= i
11 m -= 1
12 return m

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected