Problems on Linked Lists for Interviews and Self Assessment
I will list down some problems on the topic of linked lists that are commonly asked in interviews.
Important concepts to revise before trying out the problems:
- Linked List
- Node of a Linked List
- Singly Linked List
- Doubly Linked List
- Inserting and deleting nodes in a Linked List
- Runner technique - There will be more pointers and they will move forward at different speeds.
- Reverse a linked list
- Remove duplicates from a sorted linked list.
- Remove duplicates from an unsorted linked list.
- Find the Kth to last element in a linked list
- Delete a node in the middle of a singly linked list, given only access to that node.
- Given a linked list with a loop (circular linked list), find the node at the beginning of the loop.
- Partitian a linked list around a given value x, with all nodes with values less than x should come before all nodes with values greater than or equal to x.
Given two sorted (ascending) linked lists L1 and L2. Write a program to merge them into a single descending linked list.
- List1 = 5>15>25>35>null.
- List2 = 1>10>20>30>null.
- ResultList = 35>30>25>20>15>10>5>1>null.
- Find the middle element of linked list in one Pass?
- I will add more to the list whenever I come across a new one.
- If you were asked a problem not listed here, please let us know and we will add it here. You will also receive points. If you can provide a good solution and explanation also for your problem, you will get extra points and even cash prizes.
Refer to individual problems under corresponding problem category for solutions.