A runtime component at HashedIn by Deloitte receives linked lists representing processing chains. Determine whether the chain eventually loops back to a previously visited node.
Implement contains_loop(nodes, head) using constant auxiliary space.
nodes is a list where each element has the form [value, next_index].value is an integer payload and next_index is the zero-based index of the next node.next_index of -1 represents the end of the list.head is the index of the first node, or -1 for an empty list.True if the nodes reachable from head contain a cycle. Otherwise, return False.head must not affect the result.def contains_loop(nodes, head):