This code failed for one test case. please check once
Hey @gaganpreetsachdev1
Your code is not able to work for 2 cases when K > lth of LL
when K== lth of LL
For
1 2 4 -1
3
Output should be 1
For
1 2 3 -1
4
Output should be 3
Here u dont have to handle K>Length of LL
So only handle when K==length of LL
Hint: Add a dummy node