This is my CPP solution.
class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
ListNode* origHead = head;
while(head){
ListNode* later = head->next;
while(later && (later->val == head->val)){
later = later->next;
}
if(!later){
head->next = NULL;
break;
}
else{
head->next = later;
}
head = head->next;
}
return origHead;
}
};