LIFE CODING WITH JAVA
Find a Node in Linked List
Send Feedback
You have been given a singly linked list of integers. Write a function that returns the index/position of integer data denoted by 'N' (if it exists). Return -1 otherwise.
Note :
Assume that the Indexing for the singly linked list always starts from 0.
Sample Input 1 :
2
3 4 5 2 6 1 9 -1
5
10 20 30 40 50 60 70 -1
6
Sample Output 1 :
2
-1
Explanation for Sample Output 1:
In test case 1, 'N' = 5 appears at position 2 (0-based indexing) in the given linked list.
In test case 2, we can see that 'N' = 6 is not present in the given linked list.
Sample Input 2 :
2
1 -1
2
3 4 5 2 6 1 9 -1
6
Sample Output 2 :
-1
4
Explanation for Sample Output 2:
In test case 1, we can see that 'N' = 2 is not present in the given linked list.
In test case 2, 'N' = 6 appears at position 4 (0-based indexing) in the given linked list.
I try to solve very easy concept So please watch this video .
All java code with easy trick.
By "LIFE CODING WITH JAVA". all program free no any cost So please like ,subscribe, share and comment.
If you any doubt related to any video then comment me. As soon as I will help you .
my contact number: 6206472735..
#LIFE CODING WITH JAVA
@java62
#java
#coding
#with java
#for loops in java
#patterns in java
#while loops in java
#arrays in java
#dynamic in java
#linked list in java
#queue in java
#stack in java
#binary search in java
#merge search in java
#dsa in java
#recursion in java
#arraylist in java
#function in java
#all oops concept in java
#queue
#explain all concept related to java
#history of java
#only java course
#full stack web development
#coding ninjas all questions