Skip to content

Latest commit

 

History

History
43 lines (29 loc) · 1.14 KB

0082-remove-duplicates-from-sorted-list-ii.adoc

File metadata and controls

43 lines (29 loc) · 1.14 KB

82. Remove Duplicates from Sorted List II

{leetcode}/problems/remove-duplicates-from-sorted-list-ii/[LeetCode - Remove Duplicates from Sorted List II^]

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.

Example 1:
Input: 1->2->3->3->4->4->5
Output: 1->2->5
Example 2:
Input: 1->1->1->2->3
Output: 2->3

解题分析

快慢指针是个好办法!

注意推敲满指针前进的条件!

link:{sourcedir}/_0082_RemoveDuplicatesFromSortedListII.java[role=include]
link:{sourcedir}/_0082_RemoveDuplicatesFromSortedListII_2.java[role=include]