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
{
"a": [
1,
3,
5
],
"b": [
2,
4,
6
]
}
Execution steps
Take smaller head
Computed output
[
1,
2,
3,
4,
5,
6
]
JavaScript reference implementation
const solve = ({
a,b
},s)=>{
let i=0,j=0,o=[];
while(i<a.length||j<b.length){
o.push(j===b.length||i<a.length&&a[i]<=b[j]?a[i++]:b[j++]);
s("Take smaller head",{
A:a,B:b,Output:o,Pointers:[i,j]
})
}
return o
};