Susquehanna International Group (SIG) Interview Question: How to reverse the link list?... | Glassdoor

Interview Question

Software Engineer Interview Philadelphia, PA

How to reverse the link list?

data structures

Interview Answer

1 Answer


given list a with a->b->c
and where each element has a .next field
reverse the list.

requires three variables: next, prev, cur

start by setting next to the head of the list, a.
and prev to null (0)

next = a
prev = 0
cur = 0

   if (next == 0)
   cur = next
   next = = prev
   prev = cur

anonymous on Aug 25, 2012

Add Answers or Comments

To comment on this, Sign In or Sign Up.