public class Solution {
public int uniquePaths(int m, int n) {
if (m < n) {
int temp = m;
m = n;
n = temp;
}
int[] path = new int[n];
for (int j = 0; j < n; j++) {
path[j] = 1;
}
for (int i = 1; i < m; i++) {
path[0] = 1;
for (int j = 1; j < n; j++) {
path[j] += path[j - 1];
}
}
return path[n - 1];
}
}