You are viewing a single comment's thread. Return to all comments →
Python - T: O(n) / S: O(1)
def removeDuplicates(self, head): if not head or not head.next: return head curr = head prev = None last_seen = None while curr: if curr.data == last_seen: prev.next = curr.next else: last_seen = curr.data prev = curr curr = curr.next return head
Seems like cookies are disabled on this browser, please enable them to open this website
Day 24: More Linked Lists
You are viewing a single comment's thread. Return to all comments →
Python - T: O(n) / S: O(1)