Re:Nth-to-Last Element in a Singly Linked List
by liamk on Sunday January 31, 2010 @11:05PM
(#1091752)
What about going through the list once, put each node onto a stack, then pop n - 1 elements off the stack, and the nth last element will be on the top of the stack.
Edit: uses too many pointers as cperciva points out below.
[ Parent
| on HN ]