Amdocs interview question

Write a program that detects a circle list