Amazon Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

A Linked list.(Each node can point to the previous and next node).It is easier to add nodes to the end of a linked list. If you use an array you would either need to resize it or initialise it to the maximum possible snake length to start(which is a waste of memory)

- Rohan July 25, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Rohan: You mean to say doubly linked list or singly linked list???

- aman August 01, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Single Linked List would be better in terms of memory. Since a snake's body length would increase every time it ate something, it is better to have pointer to the last node of the list. This would allow better insertions at the end of the list.

- Rohan August 01, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@Rohan: I accept with u. Each movement of snake need to be searched for existence of that new covered point in its list. This costs O(snake length). Its better to have extra hash as well. so searching can be done quickly.
Finally, LL for order of points covered by snake and hash to search for correctness.

- Chandu September 10, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Just a linklist for snake's body and a 2-d matrix for the game board should also suffice, right?

- Ritesh October 08, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

what has bitten the snake?

- Anonymous June 16, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More