Simple Solution 😃
\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# 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        if(head==nullptr){\n            return head;\n        }\n        ListNode* dummyNode = new ListNode(-1);\n        dummyNode -> next = head;\n        ListNode* curr = dummyNode;\n\n        while(curr->next!=nullptr&&curr->next->next!=nullptr){\n            if(curr->next->val==curr->next->next->val){\n                int duplicate = curr->next->val;\n                while(curr->next!=nullptr&&curr->next->val==duplicate){\n                    ListNode* temp = curr -> next;\n                    curr -> next = curr->next->next;\n                    delete temp;\n                }\n\n            }\n            else{\n                curr = curr->next;\n            }\n\n        }\n        return dummyNode->next;\n    }\n};\n```\n\n![i.jpg](https://assets.leetcode.com/users/images/5ee16cc9-1523-46bf-bcae-e384caf0092f_1691954059.9454777.webp)\n
['C++']