I am gettting correct output but testcases are failing
Hello @Vipul.kapoor,
In the question, you are required to find the kth element from the end of the linked list i.e. the right most node.
But, your code is printing the (k+1)th term from the head of the linked list.
Examples:
-
1 2 3 4 5 6 -1
1
Your Output:
2
Expected Output:
6 -
1 2 3 4 5 6 -1
2
Your Output:
3
Expected Output:
5
Correct it.
Hope, this would help.
Give a like if you are satisfied.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.