1 2 3 4 5 6 7 8 9 10 11 12 13 14 | public class Solution { public ListNode deleteDuplicates(ListNode head) { if (head == null) return null; ListNode current = head; while (current != null){ while (current.next != null && current.val == current.next.val){ current.next = current.next.next; } current = current.next; } return head; } } |
No comments:
Post a Comment