Interview Question

Interview

Implement an algorithm to find the 3rd to last element of a

  singly linked list of unknown size
Answer

Interview Answer

1 Answer

0

set two pointers at the head; move the first one 3 steps first; then move the two pointers at the same time, one step a time; when the first pointer reach the tail, the second pointer get the result

helloslz on Dec 25, 2013

Add Answers or Comments

To comment on this, Sign In or Sign Up.