题解 | #删除有序链表中重复的元素-I#
删除有序链表中重复的元素-I
http://www.nowcoder.com/practice/c087914fae584da886a0091e877f2c79
import java.util.*; public class Solution { public ListNode deleteDuplicates (ListNode head) { if(head==null||head.next==null) return head; ListNode p = head; ListNode q = head.next; while(q!=null){ if(p.val!=q.val){ p = p.next; q = q.next; }else{ while(q!=null && p.val==q.val) q = q.next; p.next = q; p = p.next; } } return head; } }