Delete a node with a key

Description

Flashcards on Delete a node with a key, created by Suhas S on 15/02/2018.
Suhas S
Flashcards by Suhas S, updated more than 1 year ago
Suhas S
Created by Suhas S over 7 years ago
1
0
1 2 3 4 5 (0)

Resource summary

Question Answer
Delete all occurrences of a key in a linked list public void deleteKey(ListNode head, int key){ ListNode temp = head; ListNode = prev; while(temp != null && temp.data ==key){ head = temp.next; temp= head; } while(temp!=null){ while(temp!=null && temp.data!=key){ prev = temp; temp= temp.next; } if(temp == null) return; prev.next = temp.next; temp = prev.next; } }
Show full summary Hide full summary

0 comments

There are no comments, be the first and leave one below:

Similar

Delete Node in a BST
Suhas S
Remove Nth Node From End of List
Suhas S
Swap Nodes in Pairs
Suhas S
Merge Two Sorted Lists
Suhas S
Odd Even Linked List
Suhas S
Rotate List
Suhas S
Add Two Numbers
Suhas S
Copy List with Random Pointer
Suhas S
Practice For First Certificate Grammar I
Alice McClean
I wish I..
Cristina Cabal