public int uniquePaths3(int m, int n) {
        int[] curr = new int[n + 1];
        int[] next = new int[n + 1];
        for(int i = 1; i < n + 1; i++) curr[i] = 1;

        for(int i = 2; i < m + 1; i++){
            for(int j = 1; j < n + 1; j++){
                if(j == 1){
                    next[j] = 1;
                }else{
                    next[j] = next[j - 1] + curr[j];
                }
            }
            curr = next;
        }
        return curr[n];
    }