标签:
/** * Definition for singly-linked list. * public class ListNode { * public int val; * public ListNode next; * public ListNode(int x) { val = x; } * } */ public class Solution { public void DeleteNode(ListNode node) { while(node.next!=null&&node.next.next!=null) { node.val=node.next.val; node=node.next; } if(node.next==null)return; if(node.next.next==null){ node.val=node.next.val; node.next=null; } } }
参考了https://miafish.wordpress.com/2015/07/26/leetcode-ojc-delete-node-in-a-linked-list/
标签:
原文地址:http://www.cnblogs.com/danwang/p/5551338.html