-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path114.h
More file actions
28 lines (28 loc) · 675 Bytes
/
114.h
File metadata and controls
28 lines (28 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Solution {
public:
/**
* @param n, m: positive integer (1 <= n ,m <= 100)
* @return an integer
*/
int uniquePaths(int m, int n) {
// wirte your code here
int dp[100][100];
for(int i = 0; i < 100; i++){
for(int j = 0; j < 100; j++){
dp[i][j] = 0;
}
}
dp[0][0]=1;
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
if(i > 0){
dp[i][j] += dp[i-1][j];
}
if(j > 0){
dp[i][j] += dp[i][j-1];
}
}
}
return dp[m-1][n-1];
}
};