bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 1199. Minimum Time to Build Blocks

1199. Minimum Time to Build Blocks

Leetcode Solutions

Optimal Merge Pattern with Min Heap

  1. Create a Min Heap and add all the build times of the blocks to it.
  2. While there is more than one block in the heap: a. Pop the two blocks with the smallest build times from the heap. b. Calculate the new build time as the sum of the split time and the larger of the two popped build times. c. Push the new build time back into the heap.
  3. The last remaining build time in the heap is the minimum time needed to build all blocks.
UML Thumbnail

Binary Search on Time

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...