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
"aacecaaa"
Execution steps
Test palindromic prefix
Computed output
"aaacecaaa"
JavaScript reference implementation
const solve = (a,s)=>{
let i=a.length;
while(i>0){
let p=a.slice(0,i);
s("Test palindromic prefix",{
Prefix:[...p]
});
if(p===[...p].reverse().join(""))return [...a.slice(i)].reverse().join("")+a;
i--
}
return a
};