Challenge 3: Deletion by Value
Based on how you handled the deletion at head strategy, write the function for deletion by value.
We'll cover the following
Problem statement
Implement the Delete functionality. In this function, you will pass a particular value that you want to delete from the list. The node containing this value could be anywhere on the list. It is also possible that such a node may not exist at all.
Therefore, you would have to traverse the whole list until you find the value, which needs to be deleted. If the value does not exist, you do not need to do anything.
Input
A value to be deleted is the input.
Output
true
if the value is deleted but false
otherwise.
Sample input
LinkedList = 1->2->3->4->5
Value = 4
Sample output
true
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.