4
ListNode *deleteDuplicates(ListNode *head) {6
if (head == NULL || head->next == NULL) return head;8
// we are giving next pointer to recursion and telling it to get it done for10
ListNode *newNode = deleteDuplicates(head->next); // 1-2-3-311
// after recursion we will get-- 1-2-313
// now we will compare the head node with the newNode14
// if both are same then return the newNode15
// else return the current head16
if (head->val == newNode->val)28
ListNode *deleteDuplicates(ListNode *head) {29
if (head == NULL || head->next == NULL) return head;31
ListNode *temp = head;32
while (temp->next != NULL) {33
// if the 2 consecutive nodes are equal then just delete the in between34
if (temp->val == temp->next->val) {35
temp->next = temp->next->next;36
// dont need to update the temp variable as there can be more than 238
// 1-1-1-1-2-3-4-4-NULL40
temp = temp->next; // update the temp variable