Linked Lists
Understand pointer manipulation and list operations
Linked Lists are linear data structures where elements are stored in nodes. Each node contains data and a reference (link) to the next node. They excel at insertions and deletions but require sequential access.
Key Concepts
- Dynamic size - grow and shrink at runtime
- Efficient insertions/deletions at O(1) with pointer
- No random access - requires O(n) traversal
- No wasted memory from pre-allocation
- Variants: Singly, Doubly, Circular linked lists
Problems
Reverse Linked List
EasySoonReverse a singly linked list iteratively and recursively
PointersRecursion
Merge Two Sorted Lists
EasySoonMerge two sorted linked lists into one
Two PointersRecursion
Linked List Cycle
EasySoonDetect if a linked list has a cycle
Floyd's AlgorithmTwo Pointers
Remove Nth Node From End
MediumSoonRemove the nth node from the end of the list
Two PointersOne Pass
Add Two Numbers
MediumSoonAdd two numbers represented by linked lists
MathLinked List
Copy List with Random Pointer
MediumSoonDeep copy a linked list with random pointers
Hash MapLinked List