This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function numberOfPaths (matrix) { | |
// Write your code here | |
if (matrix.length < 1) return 0 | |
// if matrix[matrix.length-1] === 0 and matrix[matrix.length -1] == 0 then return 0 | |
// set up 2d cache to cumulate the possible moves | |
const cache = Array.from(Array(matrix.length + 1), () => new Array(matrix[0].length + 1).fill(null)) | |
// set up initial values | |
cache[1][1] = 1 |