62. Unique Paths
1 | class Solution { |
Time Limit Exceeded
动态规划,划分为子路径
1 | class Solution { |
空间优化 1
2
3
4
5
6
7
8
9
10class Solution {
public:
int uniquePaths(int m, int n) {
vector<int> dp(n, 1);
for(int i = 1; i < m; ++i)
for(int j = 1; j < n; ++j)
dp[j] += dp[j - 1];
return dp.back();
}
};