Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Node DeleteNote(Node n, int d)
- {
- if (n.data == d) return n.next;
- //variable to hold node in iteration
- Node currentNode = n
- while(currentNode.next != null) {
- if (currentNode.data == d){
- //jump over the removed node
- currentNode.next = currentNode.next.next;
- break;
- }
- //point to next node in the sequence
- currentNode = currentNode.next;
- }
- return n;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement