Unique Paths
LeetCode Problem #62 (Medium)
Last updated
Was this helpful?
LeetCode Problem #62 (Medium)
Last updated
Was this helpful?
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).
How many possible unique paths are there?
Refer to the Prerequisite Knowledge section in Coin Change 2:
Create a two-dimensional vector to store the number of paths from each cell.
Initialize the number of paths from a cell in the first row or first column as 1.
Recursively count the number of paths to traverse the remaining cells as the sum of the paths generated by:
a. Moving to the right cell
b. Moving to the bottom cell
Return the value in the last cell as the number of unique paths from the starting point to the ending point.