Remove Duplicates from Sorted List -- LeetCode Solution in C
You can use a simple recursive method like this: basically, we only need to care about the previous node and current node when deleting a node.

ListNode* deleteDuplicates(struct ListNode* head) {
     deleteDuplicates(NULL, head);
     return head;
}

void deleteDuplicates(struct ListNode* pre, struct ListNode* cur) {
   if(cur == NULL)
      return;
   if(pre == NULL){
      deleteDuplicates(cur, cur-&gt;next);
   }else if(pre-&gt;val == cur-&gt;val){//Delete duplicate node
      pre-&gt;next = cur-&gt;next;
      deleteDuplicates(pre, pre -&gt;next);
   }else{//The current node doesn't need to be deleted, move forward
      deleteDuplicates(cur, cur-&gt;next);
   }
}