Back to problems

Stack Items into the Shortest Column (Min-Heap Load Balancing)

Algorithm · Pinterest · Medium

Requirements Items are processed in their given order, and every item has a positive integer height. Assign each item to the column with the smallest accumulated height at that moment. If several columns share that minimum, use the leftmost one. Solve the initial version with two columns, then explain how the same idea extends to k columns. Implement the following function, returning the final accumulated heights from left to right: Give both the time and auxiliary-space…

Checking your access…