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
[
1,
0,
1,
1,
1
]
Execution steps
Update consecutive run
Computed output
3
JavaScript reference implementation
const solve = (a,s)=>{
let r=0,b=0;
a.forEach((x,i)=>{
r=x===1?r+1:0;
b=Math.max(r,b);
s("Update consecutive run",{
Array:a,Run:[r],Best:[b]
},[i])
});
return b
};