The first line of the input contains space-separated integers denoting the values of nodes of the Linked List.
The Linked List is terminated with -1. Hence, -1 is never a node value of the Linked List.
The second line contains a single integer 'K', which is desired to be checked in the Linked List.
The only line contains 1 if the desired value 'K' exists in the Linked List, otherwise, print 0.
You do not need to print anything; it has already been handled. Just implement the given function.
Let's try to build a recursive solution to this problem
The recursive function has three cases:
The idea is to first initialize a pointer pointing to the first element of the Linked List and will check if the pointer's data is equal to the desired value ‘K’. If yes, then we will return 1; otherwise, we will move the pointer ahead by 1 position. If at any point of time during our travel, the pointer gets to point the NULL node, i.e., the end of Linked List, we will return 0 (as we have reached the end).
Deletion In Doubly Linked List
Deletion In Doubly Linked List
Insertion In Doubly Linked List
Insertion In Doubly Linked List
LRU Cache
Delete Nodes On Regular Intervals
Add One To Linked List