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
[
3,
1,
2,
5,
3
]
Execution steps
Count value 3
Count value 1
Count value 2
Count value 5
Computed output
[
3,
4
]
JavaScript reference implementation
const solve = (a,s)=>{
let c=Array(a.length+1).fill(0);
a.forEach((x,i)=>{
c[x]++;
s("Count value "+x,{
Array:a,Counts:c
},[i])
});
return [c.findIndex(x=>x===2),c.findIndex((x,i)=>i>0&&x===0)]
};