Algorithm · Amazon · Medium
Given the head of a singly linked list, create a function find_middle_and_cycle(head) that identifies its middle node. When the list loops back on itself, also determine the node where that loop begins. Return both the midpoint and, when applicable, the cycle's entry node. Input Details: The linked list's head node. In the space-separated serialization, node values are listed in order and -1 -1 marks the end of the input; these markers are not node values. Output Details:…
Checking your access…