Company: Squarepoint
Difficulty: medium
Lexicographically Smallest Bottom Row Problem Description You are given a collection of shelves, where each shelf is represented as a list of integers. The shelves can have different lengths. You are allowed to rearrange the shelves in any order, but the order of integers within a shelf cannot be changed. After placing the shelves in some order, imagine arranging them vertically as columns and applying gravity: Numbers in each column "fall" to the lowest available position, so that there are no empty gaps at the bottom of any column. Once gravity has been applied, consider the bottom row of the resulting grid. Your task is to determine the lexicographically smallest possible bottom row that can be achieved by reordering the shelves.