Unique Paths
viaLeetCode
Problem: A robot is located at the top-left corner of an m x n grid. 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. How many possible unique paths are there?
Constraints: 1 <= m, n <= 100.
Example: m=3, n=7 -> 28 unique paths.
Approach: Classic 2D DP: dp[i][j] = dp[i-1][j] + dp[i][j-1], base case dp[0][]=dp[][0]=1. Can be optimized to O(n) space using a rolling 1D array. Combinatorics closed form C(m+n-2, m-1) also works.
asked …