Fortinet interview question

Reverse the list, detect and remove loops.