Linked Lists

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 points

  • 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

Easy

Reverse a singly linked list iteratively and recursively

PointersRecursion
Open

Merge Two Sorted Lists

Coming soon

Merge two sorted linked lists into one

Two PointersRecursion

Linked List Cycle

Coming soon

Detect if a linked list has a cycle

Floyd's AlgorithmTwo Pointers

Remove Nth Node From End

Coming soon

Remove the nth node from the end of the list

Two PointersOne Pass

Add Two Numbers

Coming soon

Add two numbers represented by linked lists

MathLinked List

Copy List with Random Pointer

Coming soon

Deep copy a linked list with random pointers

Hash MapLinked List