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": "anagram",
"b": "nagaram"
}
Execution steps
Count first word
Subtract second word
Computed output
true
JavaScript reference implementation
const solve = ({
a,b
},s)=>{
let m=new Map;
for(let x of a){
m.set(x,(m.get(x)||0)+1);
s("Count first word",{
Counts:[...m].map(p=>p.join(":"))
})
}
for(let x of b){
m.set(x,(m.get(x)||0)-1);
s("Subtract second word",{
Counts:[...m].map(p=>p.join(":"))
})
}
return [...m.values()].every(x=>!x)
};