Skip to content

Instantly share code, notes, and snippets.

View bluesockets's full-sized avatar
💭
PAIN is just the French word for bread

Antonio Gonzalez bluesockets

💭
PAIN is just the French word for bread
View GitHub Profile
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