✅ C++ || Easy To Understand || Iteration || Simple
82. Remove Duplicates from Sorted List II\n\n#### APPROACH -\nCreate a dummyHead with dummyHead->next = head\nTraverse through the linked list with intially isD
**82. Remove Duplicates from Sorted List II**\n\n#### **APPROACH -**\n*Create a **dummyHead** with `dummyHead->next = head`\nTraverse through the linked list with intially `isDuplicate = false`\nMove through the nodes till same valued nodes present and update **isDuplicate**\nSet the new links based on whether the current node is a duplicate\nReturn **dummyHead->next***\n</br>\n#### **COMPLEXITY -**\n* Time Complexity : O(N)\n* Space Complexity : O(1)\n</br>\n#### **CODE -**\n```\nclass Solution {\npublic:\n    ListNode* deleteDuplicates(ListNode* head) {\n        ListNode *dummyHead = new ListNode(0, head);\n        ListNode *prev = dummyHead, *curr = head;\n        \n        while(curr) {\n            bool isDuplicate = false;\n            while(curr->next && curr->val == curr->next->val) {\n                isDuplicate = true;\n                curr = curr->next;\n            }\n            if(isDuplicate)\n                prev->next = curr->next;\n            else\n                prev = curr;\n            curr = curr->next;\n        }\n\t\t\n        return dummyHead->next;\n    }\n};\n```\n\n**Please Upvote if it helps** \u2B06\uFE0F
['Linked List', 'C', 'Iterator', 'C++']