Javascript Solution


  • 0
    O
    const uniquePaths = (m, n) => {
        const makeMatrix = (m, n) => Array(m).fill(Array(n).fill(1));
        let matrix = makeMatrix(m, n);
        for(let i = 1; i < m; i++) {
            for(let j = 1; j < n; j++) {
                matrix[i][j] = matrix[i-1][j]+matrix[i][j-1];
            }
        }
        return matrix[m-1][n-1];
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.