BOTH RECURSIVE AND ITERATIVE [C++]
\n         //iterative\n\t\t \n        class Solution {\n        public:\n            ListNode deleteDuplicates(ListNode head) {\n                if(head==NULL 
\n         //iterative\n\t\t \n        class Solution {\n        public:\n            ListNode* deleteDuplicates(ListNode* head) {\n                if(head==NULL ||head->next==NULL)\n                    return head;\n                ListNode *tail= new ListNode(-1);\n                ListNode* newhead=tail;\n                while(head!=NULL){\n                    if(head->next!=NULL && head->val==head->next->val){\n                        int curr=head->val;\n                        head=head->next;\n                        while(head && head->val==curr)\n                            head=head->next;\n                    }else{\n                        tail->next=head;\n                        tail=tail->next;\n                        head=head->next;\n                    }\n                }\n                tail->next=NULL;\n                return newhead->next;\n            }\n        };\n\t\t\n\t\t//recursive\n\t\t\n\t\tclass Solution {\n        public:\n            ListNode* deleteDuplicates(ListNode* head) {\n                if(head==nullptr) return head;\n                ListNode* p1=head->next;\n                if(p1 && p1->val==head->val){\n                 while(p1 && p1->val==head->val) {\n                     p1=p1->next;\n                 }\n                    return deleteDuplicates(p1);\n                }\n                else \n                head->next = deleteDuplicates(head->next);\n                return head;\n            } \n        };\n\t\t\n**Feel free to ask any question in the comment section.\nIf you like this solution, do UPVOTE.\nHappy Coding :)**\n\t\t
['Recursion', 'C', 'C++']