Write an algorithm that checks if the the following structure is a cycled list? A structure is composed of nodes with 2 properties: id, id of the next node. If id of the next node is null then the node is the last one.
My first idea had complexity of O(n²). The repository contains the code.
The code is a solution to a question asked on my first inteview ever (2014).