C++ solution, simple and easy to understand
Simply check if the element is duplicate. If yes, record it and use a while loop to go to the next unique element.\n\n    class Solution {\n    public:\n       
Simply check if the element is duplicate. If yes, record it and use a while loop to go to the next unique element.\n\n    class Solution {\n    public:\n        ListNode* deleteDuplicates(ListNode* head) {\n            ListNode* dummy = new ListNode(0);\n            dummy->next = head;\n            ListNode* cur = dummy;\n            int duplicate;\n            while (cur->next && cur->next->next) {\n                if (cur->next->val == cur->next->next->val) {\n                    duplicate = cur->next->val;\n                    while (cur->next && cur->next->val == duplicate) {\n                        cur->next = cur->next->next;\n                    }\n                }\n                else {\n                    cur = cur->next;\n                }\n            }\n            return dummy->next;\n        }\n    };
[]