1. 程式人生 > >鏈表去重

鏈表去重

oid node div brush data lis pre move clas

private void RemoveDupNode(List<Node> list)
{

    Node head =list[0];
    Node p,q,r;
    while(p!=null)
    {
		q = p;
		while(q.next!=null)
		{
			if(q.next.data == p.data)
			{
				r = q.next;
				q.next = r.next;
				list.remove(r);
			}
			else
				q = q.next;
		}
		p = p.next;
    }
 
}        

  

鏈表去重