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,
2,
-4
]
Execution steps
Place by sign
Computed output
[
3,
-2,
1,
-5,
2,
-4
]
JavaScript reference implementation
const solve = (a,s)=>{
let p=0,n=1,o=Array(a.length).fill(null);
a.forEach((x,i)=>{
if(x>=0){
o[p]=x;
p+=2
}else{
o[n]=x;
n+=2
}
s("Place by sign",{
Array:a,Output:o
},[i])
});
return o
};