Pinterest interview question

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