AC and Best Solution
1 |
def (self, head): |
Time complexity: O(n)
Space complexity: O(1)
use two pointer, fast pointer(pointer) go faster than slow pointer
if fast pointer = slow pointer, means duplicates starts
keep fast pointer going until it reach a node have different value than slow pointer
let slow pointer.next point to that node so duplicate removed
近期评论