XYZ interview question

They only ask the logic (dry run) by giving the problem, not the exact code for problem.