The list is sorted. So we only need to compare the current node and the next node.

```
public class Solution {
public ListNode deleteDuplicates(ListNode head) {
if(head==null||head.next==null)
return head;
ListNode node=head;
ListNode nextNode=null;
while(node.next!=null)
{
nextNode=node.next;
if(node.val==nextNode.val)
node.next=nextNode.next;
else
node=node.next;
}
return head;
}
}
```