Problem
Given a linked list, return the node where the cycle begins. If there is no cycle, return null
.
Note
Do not modify the linked list.
Solution
Method: Two Pointers
Time Complexity:
Space Complexity:
1 | # Definition for singly-linked list. |
Reference
https://leetcode.com/problems/linked-list-cycle-ii/discuss/44902/Sharing-my-Python-solution