Amazon.com
3.3 of 5 3,203 reviews
www.amazon.com Seattle, WA 5000+ Employees

Amazon.com Software Development Engineer I Interview Question

I interviewed in Seattle, WA and was asked:
"Remove the nth from last element in a singularly linked list in linear time."
Add Tags [?]
Answer Flag Question

Part of a Software Development Engineer I Interview Review - one of 4,603 Amazon.com Interview Reviews

Answers & Comments

0
of 0
votes
The general idea is to keep a pointer n elements back from the current element as you're traversing the linked list looking for the last node. There are some edge cases when coding it. O(n) time, O(1) space.
- Interview Candidate on Jan 13, 2012 Flag Response
0
of 0
votes
How about? Traverse once find length. Then find n-kth element. Still linear complexity in time and 0 addl space
- kvr on Feb 20, 2012 Flag Response
0
of 0
votes
That works too. The first way you only traverse once though.
- Jordan on Feb 20, 2012 Flag Response

To comment on this question, Sign In with Facebook or Sign Up


Tags are like keywords that help categorize interview questions that have something in common.

Glassdoor is your free inside look at Amazon.com interview questions and advice. All interview reviews posted anonymously by Amazon.com employees and interview candidates.