Company: Goldman sachs_27july
Difficulty: medium
Tennis Ball Storage System Problem Description A sports shop stores tennis balls in a storage grid made of multiple rows and columns. Each slot in the grid can either be empty, contain a ball, or contain a support beam. When a ball is dropped into a column, it falls until it hits a support beam or another ball. If it hits a support beam, it settles on top of it. If it hits another ball, it settles on top of that ball. Therefore, R can also be thought of as the number of rows in the grid. Each slot in the grid can be denoted as: . (Dot) - An empty slot # (Hash) - A fixed support beam that prevents the ball from passing through O (Capital letter O) - A tennis ball that has already been placed in a slot The store uses an automated conveyor system to drop the balls into the grid. When a ball is dropped, it will always fall to the lowest previous one has settled. Due to the shape of the grid, the balls follow a particular pattern when dropped in any column: The ball falls straight down the