Given the head of a linked list, determine if the list has a cycle. A cycle exists if some node can be reached again by following next pointers.
Return true if there is a cycle, false otherwise. You must solve it with space (excluding input).
Given the head of a linked list, determine if the list has a cycle. A cycle exists if some node can be reached again by following next pointers.
Return true if there is a cycle, false otherwise. You must solve it with space (excluding input).