Skip to content

Commit c1ad6d5

Browse files
authored
Create minimum-time-to-build-blocks.py
1 parent af300e9 commit c1ad6d5

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+
# Time: O(nlogn)
2+
# Space: O(n)
3+
4+
import heapq
5+
6+
7+
class Solution(object):
8+
def minBuildTime(self, blocks, split):
9+
"""
10+
:type blocks: List[int]
11+
:type split: int
12+
:rtype: int
13+
"""
14+
heapq.heapify(blocks)
15+
while len(blocks) != 1:
16+
x, y = heapq.heappop(blocks), heapq.heappop(blocks)
17+
heapq.heappush(blocks, y+split)
18+
return heapq.heappop(blocks)

0 commit comments

Comments
 (0)