finding an element in a linked list from the end.
One of my friends was asked the following question in an interview, just a couple of days back.
Given a single linked list, how can you find out the nth element, from the end, while traversing the list only once?
I have been thinking about it? Since I do not know if the interviewer wanted him to use another list or an array to store some data, other than temporary "basic data types" variables like int i .... (I hope I am making sense here), lets assume
1.) without using another list or array
2.) using it.
Thanks,
Anoop.