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,
2,
2,
4
],
"b": [
2,
3,
5
]
}
Execution steps
Merge next distinct value
Computed output
[
1,
2,
3,
4,
5
]
JavaScript reference implementation
const solve = ({
a,b
},s)=>{
let i=0,j=0,o=[];
while(i<a.length||j<b.length){
let x=j===b.length||i<a.length&&a[i]<=b[j]?a[i++]:b[j++];
if(o.at(-1)!==x)o.push(x);
s("Merge next distinct value",{
A:a,B:b,Union:o,Pointers:[i,j]
})
}
return o
};