删除节点,也要删除这段对应的内存。。。。在php中使用unset....?垃圾回收机制??
2.2.4 Remove Duplicates from Sorted List
描述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.
function f($l)
{
$p=$l->root->next;
if($l->root==null||$p==null) return false;
$value=$p->value;
$p1=$p;
$ps=$l->root;
$p=$p->next;
while($p!=null){
if($p->value==$p1->value){
$p1->next=$p->next;
$issame=true;
}else{
$p1=$p;
}
$p=$p->next;
}
$l->showLink();
}
2.2.5