Pinterest Interview Question

Given the array of rectangles' lengths, implement the Pinterest waterfall grind.