Challenge: Deletion by Value

Try to solve the Deletion by Value problem.

We'll cover the following

Statement

Given the head of a singly linked list and a value to be deleted from the linked list, if the value exists in the linked list, delete the value and return TRUE. Otherwise, return FALSE.

Constraints:

Let n be the number of nodes in the linked list:

  • 11 \leq n 500\leq 500

  • 5000-5000 \leq Node.data 5000\leq 5000

Examples

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.