Kth element from last in linked list


one test case is not passing
please check my code and point out my mistake .
note: please don’t edit the code. leave this job for me so that i can learn more.

Hello @sk3657860,

Your code is failing for the test case when we want to print the last element from the last of the linked list.
Example 1:
1 2 3 4 5 6 -1
6
Example 2:
1 2 3 -1
3

Try to correct it.
Let me know if you still face any difficulty.

Hope, this would help.
Give a like if you are satisfied.

1 Like