Advertisement
Guest User

Untitled

a guest
May 5th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. //CC150 2.3
  2. //by dnalwqer 03/20/2015
  3. //idea: just copy the next node to the current node and delete the next one.
  4. //note: if the node is the last node in the linked list, it can not be successful. Please remember.
  5.  
  6. public void deleteMiddle(Node node) {
  7. if (node == null || node.next == null) {
  8. return ;
  9. }
  10. Node n = node;
  11. n.val = n.next.val;
  12. n.next = n.next.next;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement