Remove Duplicates from Sorted List II
2013-08-22 10:05
204 查看
public ListNode deleteDuplicates(ListNode head) { // Start typing your Java solution below // DO NOT write main() function if(head == null) return head; ListNode dummy = new ListNode(0); dummy.next = head; ListNode previous = dummy; ListNode current = head; while(current != null) { int tmp = current.val; if(current.next != null && current.next.val == tmp) { while(current != null && current.val == tmp) { current = current.next; previous.next = current; } }else { previous = current; current = current.next; } } return dummy.next; }
相关文章推荐
- LeetCode-Remove Duplicates from Sorted List II
- Remove Duplicates from Sorted List II--LeetCode
- [Leetcode] Remove Duplicates from Sorted List II
- Remove Duplicates from Sorted List II
- Remove Duplicates from Sorted List II
- [LeetCode] Remove Duplicates from Sorted List II
- Remove Duplicates from Sorted List II
- Remove Duplicates from Sorted List II
- Leetcode# 82 Remove Duplicates from Sorted List II
- Remove Duplicates from Sorted List II
- leetcode Remove Duplicates from Sorted List I && II
- [LeetCode]Remove Duplicates from Sorted List II Java
- 082 Remove Duplicates from Sorted List II [Leetcode]
- [leetcode]Remove Duplicates from Sorted List II @ Python
- Remove Duplicates from Sorted List II [LeetCode]
- Remove Duplicates from Sorted List II
- 82. Remove Duplicates from Sorted List II(Python3)
- leetCode(13):Remove Duplicates from Sorted List II
- Remove Duplicates from Sorted List II
- LeetCode2.2.5(Remove Duplicates from Sorted List II)