1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| class Solution { public ListNode deleteDuplicates(ListNode head) { ListNode curr = head;
while (curr != null) { while (curr.next != null && curr.next.val == curr.val) { curr.next = curr.next.next; }
curr = curr.next; }
return head; } }
|
References
83. Remove Duplicates from Sorted List