#K85372. Unique Paths in a Grid
Unique Paths in a Grid
Unique Paths in a Grid
Given a grid with dimensions \(m \times n\), determine the number of unique paths from the top-left corner to the bottom-right corner. At each step, you may only move either down or to the right.
For example, in a \(3 \times 2\) grid, there are 3 unique paths. The number of unique paths can be computed using dynamic programming, where each cell \(dp[i][j]\) is the sum of the cell above it and the cell to its left:
\(dp[i][j] = dp[i-1][j] + dp[i][j-1]\), with the base condition \(dp[0][0] = 1\).
inputFormat
The input consists of a single line containing two space-separated integers (m) and (n), representing the number of rows and columns of the grid respectively.
outputFormat
Output a single integer indicating the total number of unique paths from the top-left corner to the bottom-right corner of the grid.## sample
3 2
3