AC and Best Solution
1 |
def (self, head): |
Time complexity: O(n)
Space complexity: O(1)
use two pointer, fast pointer(pointer) go twise as fast as slow pointer
if fast pointer = slow pointer, means there is a cycle
1 |
def (self, head): |
Time complexity: O(n)
Space complexity: O(1)
use two pointer, fast pointer(pointer) go twise as fast as slow pointer
if fast pointer = slow pointer, means there is a cycle
近期评论