https://leetcode.com/problems/remove-duplicates-from-sorted-list/description/
Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,
Given 1->1->2, return 1->2.
Given 1->1->2->3->3, return 1->2->3.
1 public ListNode deleteDuplicates(ListNode head) {
2 if (head == null || head.next == null) return head ;
3 ListNode curr = head ;
4 /*
5 * 重点体会跳过去是什么意思 CURR =HEAD 然后改变 CURR.NEXT HEAD.next 也是会被变化的
6 * */
7 /*
8 * 1-1-1-1-2-2-3
9 * c--->
10 * ---->
11 * ------->
12 * c
13 * h------->
14 * */
15 while(curr.next!=null){
16 if (curr.val == curr.next.val){
17 curr.next = curr.next.next ;
18 } else {
19 curr = curr.next ;
20 }
21 }
22 return head ;
23 }