AC and Best Solution
1 |
def (self, head): |
Time complexity: O(n)
Space complexity: O(1)
use two pointer, fast pointer(pointer) always one step more than slow pointer(end)
store next node of fast pointer, let fast pointer point to slow pointer, then both pointer go to next
近期评论