Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //CC150 2.3
- //by dnalwqer 03/20/2015
- //idea: just copy the next node to the current node and delete the next one.
- //note: if the node is the last node in the linked list, it can not be successful. Please remember.
- public void deleteMiddle(Node node) {
- if (node == null || node.next == null) {
- return ;
- }
- Node n = node;
- n.val = n.next.val;
- n.next = n.next.next;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement