題目描述
實現一個算法,刪除單向鏈表中間的某個結點,假定你只能訪問該結點。
給定帶刪除的節點,請執行刪除操作,若該節點為尾節點,返回false,否則返回true
public boolean removeNode(ListNode pNode) {
// write code here
if(pNode == null){
return false;
}
if(pNode.next == null){
pNode=null;
return true;
}
pNode.val=pNode.next.val;
pNode.next=pNode.next.next;
return true;
}