✅✅Beats 100%🔥C++🔥Python|| 🚀🚀Super Simple and Efficient Solution🚀🚀||🔥Python🔥C++✅✅
Complexity
Time complexity: O(n)

Space complexity: O(1)
⬆️👇⬆️UPVOTE it⬆️👇⬆️Code⬆️👇⬆️UPVOTE it⬆️👇⬆️
# Complexity
- Time complexity: $$O(n)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: $$O(1)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
⬆️👇⬆️UPVOTE it⬆️👇⬆️
# Code
```cpp []
class Solution {
 public:
  ListNode* deleteDuplicates(ListNode* head) {
    ListNode dummy(0, head);
    ListNode* prev = &dummy;
    while (head) {
      while (head->next && head->val == head->next->val)
        head = head->next;
      if (prev->next == head)
        prev = prev->next;
      else
        prev->next = head->next;
      head = head->next;
    }

    return dummy.next;
  }
};
```
```python []
class Solution:
  def deleteDuplicates(self, head: ListNode) -> ListNode:
    dummy = ListNode(0, head)
    prev = dummy
    while head:
      while head.next and head.val == head.next.val:
        head = head.next
      if prev.next == head:
        prev = prev.next
      else:
        prev.next = head.next
      head = head.next
    return dummy.next 
```
⬆️👇⬆️UPVOTE it⬆️👇⬆️
['Linked List', 'Two Pointers', 'C++', 'Python3']