Coding Trainer

Unique Paths

MediumDynamic Programmingk-dynamic-programmingLC #62

Problem

Unique Paths

There is a robot on an m × n grid, starting at the top-left corner. The robot can only move either down or right at any point in time, trying to reach the bottom-right corner.

Return the number of possible unique paths.

Example 1:

Input: m = 3, n = 7
Output: 28

Example 2:

Input: m = 3, n = 2
Output: 3
Explanation: From top-left, there are 3 paths to reach bottom-right: Right->Down->Down, Down->Right->Down, Down->Down->Right.

Constraints:

  • 1 ≤ m, n ≤ 100