diff --git a/linked_lists/remove_duplicates/remove_duplicates_solution.ipynb b/linked_lists/remove_duplicates/remove_duplicates_solution.ipynb index 1e43301..77f598b 100644 --- a/linked_lists/remove_duplicates/remove_duplicates_solution.ipynb +++ b/linked_lists/remove_duplicates/remove_duplicates_solution.ipynb @@ -127,6 +127,20 @@ " if self.head is None:\n", " return\n", " node = self.head\n", + " seen_data = set()\n", + " while node is not None:\n", + " if node.data not in seen_data:\n", + " seen_data.add(node.data)\n", + " prev = node\n", + " node = node.next\n", + " else:\n", + " prev.next = node.next\n", + " node = node.next\n", + "\n", + " def remove_dupes_single_pointer(self):\n", + " if self.head is None:\n", + " return\n", + " node = self.head\n", " seen_data = set({node.data})\n", " while node.next is not None:\n", " if node.next.data in seen_data:\n",