[recommend for beginners]C++ implementation with detailed explaination
At the first glance, we can use the similar code of the simpler problem : which only delete the duplicate ones, So if we want to delete all the duplicate ones i
At the first glance, we can use the similar code of the simpler problem : which only delete the duplicate ones, So if we want to delete all the duplicate ones including the copy. We can use  the dummy node and the pre pointer to jump over all the duplicate nodes.\nThe Trap is that you may ignore that when we meet the no-duplicate numbers, we should do different op based the previous states. Just like state-machine.\nAt last but not least important, we should delete the duplicate number occurs at the end . \n\n    class Solution {\n    public:\n        ListNode* deleteDuplicates(ListNode* head) {\n            if(!head)   return NULL;\n            ListNode* dummy=new ListNode(INT_MAX);\n            dummy->next=head;\n            ListNode* pre=dummy, *cur=head, *next=head->next;\n            bool flag=false;\n            while(next){\n                if(next->val==cur->val){\n                    flag=true;\n                    next=next->next;\n                }\n                else{\n                    if(flag) {\n                        pre->next=next;\n                        cur=next;\n                        next=next->next;\n                    }\n                    else{\n                        pre=pre->next;\n                        cur=cur->next;\n                        next=next->next;\n                    }\n                    flag=false;\n                }\n            }\n            //the corner cases : if the duplicate number locates at the end \n            if(flag) pre->next=next;\n            return dummy->next;\n        }\n    };
[]