I m using an array to store the number of occurrences of each element,i have taken assumption dat elements are less than 100 and greater than -100

```
int A[200]={0};
ListNode *temp=head,*prev=head;
while(temp)
{
if(temp->val<0)
A[temp->val+200]++;//if element is negative then add size of array to it
else //so that index always remain positive
A[temp->val]++;
temp=temp->next;
}
temp=head;
while(temp)
{
if((temp->val<0 && A[temp->val+200]>1)||(temp->val>=0&&A[temp->val]>1))
{
if(temp==head)
{ //if head is deleted than change head
head=temp->next;
prev=head;
free(temp);
temp=head;
}
else
{ //otherwise just delete temp
prev->next=temp->next;
free(temp);
temp=prev->next;
}
}
else
{
prev=temp;
temp=temp->next;
}
}
return head;
```

it takes O(n) for both running time n space.

any advice in improving it??