```
class Solution {
public:
int uniquePaths(int m, int n) {
int dp[n];
dp[n-1] = 1;
for ( int i = 0; i < n-1; i++ )
dp[i] = 0;
for ( int i = m-1; i >= 0; i-- ) {
for ( int j = n-2; j >= 0; j-- ) {
dp[j] = dp[j+1] + dp[j];
}
}
return dp[0];
}
};
```