author: Blankj blog : http://blankj.com time : 2017/05/10 desc :
| 11 | * </pre> |
| 12 | */ |
| 13 | public class Solution { |
| 14 | public ListNode deleteDuplicates(ListNode head) { |
| 15 | if (head == null || head.next == null) return head; |
| 16 | ListNode curr = head; |
| 17 | while (curr.next != null) { |
| 18 | if (curr.next.val == curr.val) { |
| 19 | curr.next = curr.next.next; |
| 20 | } else { |
| 21 | curr = curr.next; |
| 22 | } |
| 23 | } |
| 24 | return head; |
| 25 | } |
| 26 | |
| 27 | public static void main(String[] args) { |
| 28 | Solution solution = new Solution(); |
| 29 | ListNode.print(solution.deleteDuplicates(ListNode.createTestData("[1,1,2]"))); |
| 30 | ListNode.print(solution.deleteDuplicates(ListNode.createTestData("[1,1,2,3,3]"))); |
| 31 | } |
| 32 | } |
nothing calls this directly
no outgoing calls
no test coverage detected