The time and space complexity of the most efficient algorithm designed to find the kth node from the end of a linked list which has n nodes is
- O(1), O(1)
- O(n), O(1)
- O(n), O(n)
- O(n2), O(1)
The answer given is d.
Why is it not option b ??
To check kth node from end, its enough to have a slow pointer which starts after kth position. By the time last node is reached, the slow pointer will be in the kth node from end. So its only O(n).