/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNode *next) : val(x), next(next) {}
* };
*/
class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
if(head==NULL or head->next==NULL){
return head;
}
ListNode* c = new ListNode(head->val);
ListNode* d = c;
int data = head->val;
while(head!=NULL){
if(head->val==data){
head = head->next;
}
else{
c->next = new ListNode(head->val);
c = c->next;
data = head->val;
head = head->next;
}
}
//c->next = NULL;
return d;
}
};