public class Solution {
public ListNode deleteDuplication(ListNode head)
{
if(head==null||head.next==null)
return head;
ListNode vHead = new ListNode(-1);
vHead.next = head;
ListNode p = vHead;
ListNode q = p.next;
while (p.next!=null) {
while (q!=null && p.next.val == q.val) q = q.next;
if ( p.next.next == q) p = p.next;
else p.next = q;
q=p.next;
}
return vHead.next;
}
}
感谢你的思路..我觉得你的代码最后一个q=p.next; 多余了..因为经过if else判断之后,q=p.next是必然的吧