Amazon Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




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

Dude... could you be a bit more clear with your question.

"Add two numbers in a linked list using a stack?"

Why would I require stack or recursion to add 'two' numbers?!

- Anonymous September 12, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Anonymous ..I guess .he meant every node stores one digit

- anand September 12, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I don't think he expect the implementation of stack and linkedlist as the time is limited in phone interview and he has to ask other questions...

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

// l1, l2 be the linked lists
stack *s;
void main() {
reverse(l1) ;
reverse (l2);
s = (stack*) malloc(sizeof(stack));
add (l1, l2);
while(!isEmpty(s))
print pop();
}

void add (stack *l1, stack *l2, int carry) {

if(l1 == null && l2 == null) return;

if(l1 == null) a1 = 0;
else if(l2 == null) a2 = 0;

if(!l1)
a1 = l1->val;
if(!l2)
a2 = l2->val;
a3 = a1 + a2 + carry;
push(a3 % 10);

if(!l1 && !l2)
recurse(l1->next, l2->next, a3 / 10)
else if(!l1)
recurse(l1, l2->next, a3 / 10)
else if(!l2)
recurse(l1->next, l2, a3 / 10)
}

- Anonymous September 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

what's carry?>

- Anonymous October 05, 2011 | Flag


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