Work in HR or Recruiting?
Amazon.com
3.3 of 5 1,864 reviews
www.amazon.com Seattle, WA 5000+ Employees

204 interview experiences Back to all Amazon.com Interview Questions & Reviews

Interview Question for Software Development Engineer Co-op at Amazon.com:
Apr 30, 2012

How to print a link list reversely


Tags: data structures
Add Tags [?]

See more for this Amazon.com Software Development Engineer Co-op Interview

Helpful Question?  
Yes | No
Inappropriate?

Answers & Comments (2)

1 of 1 people found this helpful

Jun 16, 2012

by Vikas:

The simplest solution would be:

1. Traverse a linked list from head to tail
2. During traversal, push all the elements of the node into a stack
3. Once the traversal is done, pop all elements and this will print the linked list in reverse order ...

Looking fwd for an optimized solution ...
Helpful Answer?  
Yes | No
Inappropriate?

Sep 25, 2012

by anonymous:

void printLLreverse(Node *headNode)
{
    //this is going to just iterate through the LL
    //add each element to a stack and
    //print the stack when we are finished
    stack <int> llStack;
    Node* currNode = headNode;
    while(currNode)
    {
        llStack.push(currNode->data);
        currNode = currNode->next;
    }
    while(llStack.size() > 0)
    {
        cout << llStack.top();
        llStack.pop();
    }
}
Helpful Answer?  
Yes | No
Inappropriate?

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

Amazon.com – Why Work for Us?

At Amazon, we believe that everyone is a leader—it's part of what makes us 100% Peculiar. Whether you are a Software Development Engineer, Product Manager, Fulfillment Associate, or Customer Service Representative, you… Full Overview

Provided by employer [?]

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