Follow the computed execution on the reference input. Advance one step at a time, inspect the changing values and compare your prediction with the final output.
Example input
[
[
0,
0,
0
],
[
0,
1,
0
],
[
0,
0,
0
]
]
Execution steps
Add paths from left and above
Computed output
2
JavaScript reference implementation
const solve = (a,s)=>{
let d=a.map(r=>r.map(()=>0));
for(let i=0;
i<a.length;
i++)for(let j=0;
j<a[i].length;
j++){
d[i][j]=a[i][j]?0:i===0&&j===0?1:(d[i-1]?.[j]||0)+(d[i][j-1]||0);
s("Add paths from left and above",{
Grid:a,DP:d,Cell:[i,j]
})
}
return d.at(-1).at(-1)
};