Fortinet Interview Question

Reverse the list, detect and remove loops.