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,
3,
4,
5
],
"k": 2
}
Execution steps
Connect tail to head
Break circular link
Computed output
[
4,
5,
1,
2,
3
]
JavaScript reference implementation
const solve = ({
a,k
},s)=>{
let cut=a.length-k%a.length;
s("Connect tail to head",{
Nodes:a,NewHead:[cut]
});
let o=a.slice(cut).concat(a.slice(0,cut));
s("Break circular link",{
Nodes:o
});
return o
};