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
[
2,
3,
2
]
Execution steps
Choose rob or skip
Computed output
3
JavaScript reference implementation
const solve = (a,s)=>{
function f(a){
let p=0,q=0;
for(let x of a){
[p,q]=[q,Math.max(q,p+x)];
s("Choose rob or skip",{
Houses:a,Previous:[p,q]
})
}
return q
}
return Math.max(f(a.slice(0,-1)),f(a.slice(1)))
};