Cyclic Chain Detection - Coding problem | OneNoughtOne