Want a Free Job Posting?

Buy a job posting today and the second one is on us. For a limited time only. Act Now.

Interview Question

Interview(Student Candidate) Seattle, WA

Find last K elements of a linked list.


Interview Answer

1 Answer


Use 2 pointers that point to head at the start. increment one of them by k-1 Keep incrementing both until first pointer hits an end. there u have 2nd pointer pointing to the first element of the last K elements

Aashish on Mar 19, 2013

Add Answers or Comments

To comment on this, Sign In or Sign Up.