Riot Games

  www.riotgames.com
Work in HR? Unlock Free Profile

Interview Question

Anonymous Interview Santa Monica, CA

Describe how you would reverse a linked list.

Tags:
analytical
Answer

Interview Answer

1 Answer

0

I did two approaches on my answer. The first was recursive (i.e. it takes longer and uses more space the more nodes there are) and the second was linear, which ran in constant time. The prototypes looked like this:

A) Recursive:

Node * ReverseList(Node * current, Node *prev)
{

}

B) Linear

Node * ReverseList(Node * oldTopOfList)
{

}

Interview Candidate on May 12, 2013

Add Answers or Comments

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