https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/
/**
* 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) {
ListNode hhead = head;
ListNode pre = head;
while(pre != null){
while(head.next != null && head.val == head.next.val){
head = head.next;
}
pre.next = head.next;
pre = head.next;
head = pre;
}
return hhead;
}
}