https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/
http://blog.csdn.net/linhuanmars/article/details/24389429
/** * definition for singly-linked list. * public class listnode { * int val; * ListNode Next; * listnode (int x) { * val = x; * next = null; * } * } */public class solution { public listnode deleteduplicates (Listnode head) { if (head = = null | | head.next == null) return head; &Nbsp; // 1 -> 2 -> 2 -> 3 // pre test testnext next listnode pre = null; listnode test = head; listnode testnext = test.next ; boolean deletetest = false; listnode newhead = null; while (test != null) { if (Testnext != null && test.val == testnext.val) { // Delete testnext; deletetest = true; ListNode next = testnext.next; test.next = next; testnext.next = null; testnext = next; } else if ( Deletetest) { // Delete test deletetest = false; if (pre != null) { pre.next = testnext; } test.next = null; test = testnext; if (test != null) testnext = test.next; } else { pre = test; if (Newhead == null) newhead = test; test = testnext; if (test != null) testnext = test.next; } } return newhead; }}
[leetcode]82 Remove duplicates from Sorted List II