C++ || EASY TO UNDERSAND || efficient code || 3 approaches
Approach 1\nIterative method\n\nclass Solution {\npublic:\n    ListNode* deleteDuplicates(ListNode* head) {\n        ListNode* sentinel=new ListNode(0);\n      
**Approach 1**\n**Iterative method**\n```\nclass Solution {\npublic:\n    ListNode* deleteDuplicates(ListNode* head) {\n        ListNode* sentinel=new ListNode(0);\n        sentinel->next=head;\n        ListNode* pred=sentinel;\n        if(!head)\n        return NULL;\n        while(head)\n        {\n            if(head->next!=NULL&&head->val==head->next->val)\n            {\n            while(head->next!=NULL&&head->val==head->next->val)\n            {\n                head=head->next;\n            }\n                pred->next=head->next;\n            }\n            else\n            {\n                pred=pred->next;\n            }\n            head=head->next;\n        }\n        return sentinel->next;\n    }\n};\n```\n**Approach 2**\n**Recurcive solution**\n```\nclass Solution {\npublic:\n    ListNode* deleteDuplicates(ListNode* head) {\n       if(!head)\n       return NULL;\n       if(!head->next)\n       return head;\n       int value=head->val;\n        ListNode* curr=head->next;\n        if(curr->val==value)\n        {\n            while(curr&&curr->val==value)\n            {\n                curr=curr->next;\n            }\n            return deleteDuplicates(curr);\n        }\n        else\n        {\n            head->next=deleteDuplicates(curr);\n            return head;\n        }\n    }\n};\n```\n**Approach 3**\n**Creating new nodes**\n```\nclass Solution {\npublic:\n    ListNode* deleteDuplicates(ListNode* head) {\n        if(!head)\n        return NULL;\n        unordered_map<int,int> freq;\n        while(head)\n        {\n            freq[head->val]++;\n            head=head->next;\n        }\n        vector<int> v;\n        for(auto pr:freq)\n        {\n            if(pr.second==1)\n            v.push_back(pr.first);\n        }\n        if(v.size()==0)\n        return NULL;\n        sort(v.begin(),v.end());\n        ListNode* temp=new ListNode(v[0]);\n        ListNode* p=temp;\n        for(int i=1;i<v.size();i++)\n        {\n            temp->next=new ListNode(v[i]);\n            temp=temp->next;\n        }\n        temp->next=NULL;\n        return p;\n    }\n};\n```\n**Please upvote to motivate me in my quest of documenting all leetcode solutions(to help the community). HAPPY CODING:)\nAny suggestions and improvements are always welcome**
['Iterator']