Question 87 might be of interest to you before this one!
Question 88: Match the following methods to “find kth element from the end” to the “memory space” that they take.
Set 1
a) Going till the end of the linked list to find the size n, and then traverse again from the start ‘n-k’ steps.
b) Traverse two pointers, second pointer starting at the time when first pointer has reached k-1th
c) Take a queue of size ‘k’, and start enqueueing elements from the start of the linked list. When it gets full, dequeue one element and enqueue from the linked list. After all the elements of the linked list are enqueued, the next element to be dequeued will be the n-kth element from the end.
Set 2
x) O(1)
y) O(k)
z) O(1)
Options:
- a-x, b-y, c-z
- a-x, b-z, c-y
- a-y, b-x, c-z
- None of the above, all of them take O(1)
Solution: The correct answer is option 2. We need extra memory space in the algorithm where queue is involved which is of the size k. Also, see below:

In other two methods, we are just using pointers, which is O(1) memory.