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,
1
],
[
0,
1,
1
],
[
1,
1,
1
]
]
Execution steps
Move left across ones
Computed output
2
JavaScript reference implementation
const solve = (a,s)=>{
let j=a[0].length-1,b=-1;
for(let i=0;
i<a.length;
i++)while(j>=0&&a[i][j]===1){
b=i;
s("Move left across ones",{
Matrix:a,BestRow:[b],Position:[i,j]
});
j--
}
return b
};