Closed underwindfall closed 2 years ago
https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list-ii/
思路
[x] 刷15mins
[x] 刷5mins
//time O(n) //space O(1) public ListNode deleteDuplicates(ListNode head) { ListNode dummy = new ListNode(); ListNode prev = dummy; ListNode curr = head; dummy.next = curr; while (curr != null) { if (curr.next != null && curr.next.val == curr.val) { while (curr.next != null && curr.next.val == curr.val) { curr = curr.next; } prev.next = curr.next; } else { prev = curr; } curr = curr.next; } return dummy.next; }
https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list-ii/
思路
[x] 刷15mins
[x] 刷5mins