Kth element from last in ll

please help me with the code,I am really confused in ll problems
code:https://ide.codingblocks.com/s/183434

@sarthak051999 You can use Runner Technique in this question as taught by Prateek Bhaiya in the lecture videos. Please watch it again if you are confused. You will need 2 pointer- a fast pointer and a slow pointer.
First move the fast pointer k steps ahead. After that move the fast pointer and the slow pointer 1 step at a time till the fast pointer reaches the end. Ah the end, the slow pointer will be at the kth node from end. Try this taking some example of your choice to understand the logic well.
Follow this implementation:

1 Like