Pages

Monday, 3 December 2012

A comprehensive list of Linked List interview questions

  1. Remove duplicate elements from an unsorted linked list
  2. http://www.geeksforgeeks.org/sort-a-linked-list-of-0s-1s-or-2s/ - Here you are counting and doing it. However, you might have to do it in O(n). In that case, keep three pointers and keep assigning the nodes to the pointers. Keep track of edge cases 000, 111, 222,0,1,2,00111,0022.
  3. http://www.geeksforgeeks.org/reverse-a-list-in-groups-of-given-size/ : In order to solve this problem, first solve reverse a linked list recursively. Then, you can use that recursive solution here. Solved it well during practice. However, remember the code to reverse a linked list should be learnt by heart.
  4. http://www.geeksforgeeks.org/write-a-function-to-reverse-the-nodes-of-a-linked-list/
  5. http://www.geeksforgeeks.org/reverse-a-doubly-linked-list/ - reverse a doubly linked list by heart.

No comments:

Post a Comment