Unique Paths

Advanced

Unique Paths

Imagine you're exploring a magical grid world! The grid has m rows and n columns. Starting at the top-left corner (your home) and wanting to travel to the bottom-right corner (the finish), you can only move right or down in the grid.

Your task is to determine the number of unique paths (or different ways) you can take to reach from your home to the finish.

How it Works:

  1. Assume the grid doesn't contain any obstacles.
  2. You can only move right or down at any point in time.
  3. You'll need to write a function unique_paths(m, n) that computes the total number of unique paths to get from the top-left to bottom-right.

Examples:

unique_paths(3, 7) # returns 28 unique_paths(2, 2) # returns 2 unique_paths(1, 10) # returns 1 unique_paths(5, 5) # returns 70

See if you can come up with an efficient way to calculate these paths!

Happy exploring this magical grid world!

Geek
Inputs

Arg 1:

3

Arg 2:

7
Expected Output
28
Actual Output
Unique Paths [advanced] | Coding for Kids