✅ C++ || Easy To Understand || Iterative || Simple
\n1. Easy C++\n2. Line by Line Explanation with Comments.\n3. Detailed Explanation \u2705\n4. Linked list problem, Recursion.\n5. Please Upvote if it helps\u2B0
```\n1. Easy C++\n2. Line by Line Explanation with Comments.\n3. Detailed Explanation \u2705\n4. Linked list problem, Recursion.\n5. Please Upvote if it helps\u2B06\uFE0F\n```\n\n**EXPLANATION**\n\n\n* **Traverse the list** from the **head** (or start) node.\n* While traversing, **compare each node with its next node**.\n* If the data of the next node is the **same** as the current node then **skip** the next node.(don\'t add to answer)\n* If node has **unique value add to answer**  \n* Then we need **update** our pointers.\n\nTIME COMPLEXITY : O(N) , N is number of Nodes\nSPACE COMPLEXITY : O(1)\n\n\n\n\n\n```\nListNode* deleteDuplicates(ListNode* head) {\n\tif(!head || !head->next) return head; //base case\n\t\n\tListNode* prev,*start=head,*end=head;  // 3 pointers\n\tListNode* dummy=new ListNode();   // to handle corner case-> first element has duplicate\n\tprev=dummy;\n\t\n\twhile(end){\n\n\t\tif(end->next && end->val==end->next->val) {end=end->next; continue;} //skip duplicate\n\t\t\n\t\tif(!end->next && start!=end) {prev->next=NULL;break;} // to handle corner case-> last element has duplicate\n\t\t\n\t\tif(start==end) {prev->next=end, prev=prev->next;} //unique element add to answer\n\t\t\n\t\tstart=end->next, end=end->next; //update pointers\n\t}\n\t\n\treturn dummy->next; \n}\n```
['C', 'Iterator']