Search⌘ K
AI Features

Where Will the Ball Fall

Explore how to analyze a 2D grid representing a box with directional diagonals that redirect balls dropped from the top. Learn to determine if each ball will fall through the grid or get stuck by applying matrix traversal patterns and problem-solving techniques commonly seen in coding interviews. This lesson develops your ability to interpret matrix manipulations and implement efficient algorithms to solve related problems.

Statement

You have nn balls and a 2D grid of size m×nm \times n representing a box. The box is open on the top and bottom sides. Each cell in the box has a diagonal that can redirect a ball to the right or the left. You must drop nn balls at each column’s top. The goal is to determine whether each ball will fall out of the bottom or become stuck in the box. Each cell in the grid has a value of 11 ...