您的位置:首页 > Web前端 > Node.js

237. Delete Node in a Linked List

2016-04-20 09:25 393 查看
/**
* Definition for singly-linked list.
* public class ListNode {
*     int val;
*     ListNode next;
*     ListNode(int x) { val = x; }
* }
*/
public class Solution {
public void deleteNode(ListNode node) {
if(node==null||node.next==null)
return ;
ListNode temp=node;
ListNode tail=temp.next;
while(true)
{
temp.val=tail.val;
if(tail.next==null)
{
temp.next=null;
break;
}

temp=tail;
tail=tail.next;

}
}
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: