


Given ‘K’ will always be valid.
The first line of the input contains the elements of the singly linked list separated by a single space and terminated by -1. Hence, -1 would never be a list element.
The second line contains a single integer ‘K’.
Print updated list elements separated by space.
You do not need to print anything; it has already been taken care of.
1 <= N <= 5*10^5
1 <= K <= N
-10^9 <= data <= 10^9 and data != -1
Time Limit : 1 sec
First, the fundamental idea is, find the length of the linked list and then subtract the "K-1" that would be the 'K'th node from the start of the linked list. The steps are as follows:
We could optimize the way of finding the 'K'th node in Approach-1. Instead of one pointer, we could use two-pointers.