Comment
Comment by saagarjha
FWIW, I don’t particularly like this interview question since it’s dangerously close to a riddle. Sorting, graph traversal, and other algorithms are well covered by undergraduate computer science curriculums, but this algorithm is basically impossible to come up with unless you know it already and it’s not even something that you would “know to know”…