Supermicro server telemetry jobs may process records through a singly linked list. Given an encoded linked list, determine whether following its next pointers eventually revisits a node.
Use Floyd's tortoise-and-hare algorithm. The list is represented by an array of next-node indices: next_indices[i] is the index reached from node i, or -1 if the node has no successor. The list begins at head. You may assume every successor index is valid or -1.
Return true if the list contains a cycle and false otherwise. Do not modify the input.
Implement has_cycle(next_indices, head), where next_indices is a list of integers and head is an integer node index. Return a boolean.
def has_cycle(next_indices, head):