1st solution is O(m*n) space and can be optimized to the 2nd O(n) space using rolling array technique.

Is there a way to further optimize it to O(1) space dp ?

```
public class Solution {
public int uniquePaths(int m, int n) {
if (m == 0 || n == 0) {
return 0;
}
int[][] paths = new int[m][n];
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if (i == 0 || j == 0) {
paths[i][j] = 1;
} else {
paths[i][j] = paths[i - 1][j] + paths[i][j - 1];
}
}
}
return paths[m - 1][n - 1];
}
}
public class Solution {
public int uniquePaths(int m, int n) {
if (m == 0 || n == 0) {
return 0;
}
int[][] paths = new int[2][n];
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if (i == 0 || j == 0) {
paths[i % 2][j] = 1;
} else {
paths[i % 2][j] = paths[(i - 1) % 2][j] + paths[i % 2][j - 1];
}
}
}
return paths[(m - 1) % 2][n - 1];
}
}
```