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": [
2,
4,
3
],
"b": [
5,
6,
4
]
}
Execution steps
Add corresponding digits
Computed output
[
7,
0,
8
]
JavaScript reference implementation
const solve = ({
a,b
},s)=>{
let c=0,o=[];
for(let i=0;
i<Math.max(a.length,b.length)||c;
i++){
let x=(a[i]||0)+(b[i]||0)+c;
o.push(x%10);
c=Math.floor(x/10);
s("Add corresponding digits",{
A:a,B:b,Output:o,Carry:[c]
})
}
return o
};