Amazon | OA | Flattening a Linked List
Anonymous User
1201

I recently graduated b.tech and applied for amazon SDE 1 off campus hiring. Got a mail for online assesment, solved 2 questions.

Then in first online interview round, recuriter ask me falttening a linklist question

Given a linked list where every node represents a linked list and contains two pointers of its type:
(i) Pointer to next node in the main list (we call it ‘right’ pointer in the code below)
(ii) Pointer to a linked list where this node is headed (we call it the ‘down’ pointer in the code below).

  5 -> 10 -> 19 -> 28
  |    |      |     |
   V   V       V     V
   7   20     22     35
   |    |     |
   V    V     V
   8   50     40
   |    |
   V    V
   30    45
   
   output list should be 5->7->8->10->19->20->22->28->30->35->40->45->50. 
   
   As I took time to understand, only one question is asked. Next day got call you have cleared one round, next round is scheduled. Thanks .
Comments (2)