WorkspaceProblem lab
ALGORITHM VISUALIZER

Unique Grid Paths

Opening the interactive workspace…

Understanding Unique Grid Paths

Count paths from the top-left to the bottom-right of a rows by cols grid, moving only right or down.

How it works

The number of paths to a cell is the sum of paths arriving from above and from the left.

Initialize the top row to one path per cell. Process later rows left to right. Add the updated left count to the previous row count at the same column.

Try an example

Input: rows = 3, cols = 7

Output: 28

The number of paths to a cell is the sum of paths arriving from above and from the left.

Constraints

  • rows and cols are integers from 1 through 12.
  • There are no obstacles; a 1 by 1 grid has one path.

Use the simulator

Change the input, then choose Visualize input. Use Next and Previous to inspect each decision, or Play to advance automatically. Compare approaches and their complexity. Choose Try yourself to write JavaScript, select My code and Visualize code to inspect its execution, or Run Tests to check results.

Execution happens in your browser. Drafts are saved locally; avoid entering secrets or sensitive information.

Related concepts and complexity