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,
2,
3,
1
]
Execution steps
Follow slope
Computed output
2
JavaScript reference implementation
const solve = (a,s)=>{
let l=0,r=a.length-1;
while(l<r){
let m=(l+r)>>1;
s("Follow slope",{
Array:a,Bounds:[l,m,r]
},[m,m+1]);
if(a[m]<a[m+1])l=m+1;
else r=m
}
return l
};