Leetcode Problem 1199. Minimum Time to Build Blocks
1199. Minimum Time to Build Blocks
Leetcode Solutions
Optimal Merge Pattern with Min Heap
Create a Min Heap and add all the build times of the blocks to it.
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.
The last remaining build time in the heap is the minimum time needed to build all blocks.