2 pointer || O(n)
Intuition\n Describe your first thoughts on how to solve this problem. \ncreate new pointer \n# Approach\n Describe your approach to solving the problem. \n\n# 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\ncreate new pointer \n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(n)$$ \n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     int val;\n *     ListNode *next;\n *     ListNode() : val(0), next(nullptr) {}\n *     ListNode(int x) : val(x), next(nullptr) {}\n *     ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n    ListNode* deleteDuplicates(ListNode* head) {\n      ListNode* curr=head;\n       ListNode* temp = new ListNode(0);\n           temp->next = curr;\n\n        ListNode* prev=temp;\n        \n        while(curr!=NULL && curr->next!=NULL){\n     if(curr->next!=NULL && curr->val==curr->next->val){\n        while(curr->next!=NULL && curr->val==curr->next->val){\n                   curr=curr->next;\n               }\n         prev->next=curr->next;\n            }else{\n            prev=prev->next;\n            }\n            curr=curr->next;\n        }\n        return temp->next;\n    }\n};\n```
['C++']