Return true if there is a cycle in the linked list, otherwise return false.
Example 1:
Input: head = [3,2,0,-4], pos = 1
Output: true
Explanation: The tail node connects back to the node at index 1. This creates the cycle: -4 → 2
Example 2:
Input: head = [1,2], pos = 0
Output: true
Explanation: The tail node connects back to the first node, forming a cycle.
Example 3:
Input: head = [1], pos = -1
Output: false
Explanation: There is no connection back to any previous node, so the linked list does not contain a cycle.