Core Data Structures: Stacks, Queues, Linked Lists, Heaps, and Intervals Python lessons
Choosing structures by operations, monotonic reasoning, priority queues, and interval processing.
Core concepts
Problem-solving patterns
- stack · common interview
- queue · two stacks
- linked list · pointers
- fast slow pointers · linked list
- Floyd cycle · linked list
What this topic builds
Learn the idea once, trace it through two verified cases, then explain why your approach works.
All 15 lessons in this topic
Work from top to bottom to build each concept gradually.
- #122Validate brackets with a stackBeginnerPremium
Validate a correctly nested sequence of three bracket types.
- #123Implement a queue with two stacksIntermediatePremium
Process enqueues, a peek, and removals in first-in-first-out order.
- #124Reverse a linked listIntermediatePremium
Reverse the links in a five-node chain.
- #125Find the middle linked-list nodeIntermediatePremium
Return the central node from an odd number of nodes.
- #126Detect a linked-list cycleAdvancedPremium
Detect a tail that points back to an earlier node.
- #127Merge k sorted listsAdvancedPremium
Merge three sorted integer feeds into one ordered stream.
- #128Add numbers stored in linked listsAdvancedPremium
Add two numbers whose digits are stored least-significant first.
- #129Copy a random-pointer listInterview-LevelPremium
Deep-copy a list whose random pointers target several nodes.
- #130Reorder a linked listInterview-LevelPremium
Reorder nodes as first, last, second, second-last, and so on.
- #131Implement an LRU cacheInterview-LevelPremium
Process cache operations and evict the least recently used key at capacity.
- #132Implement a minimum stackInterview-LevelPremium
Return the current minimum as values are pushed and removed.
- #133Find warmer-day waitsInterview-LevelPremium
For each day, count how long until a warmer temperature appears.
- #134Find the largest histogram rectangleInterview-LevelPremium
Find the maximum rectangle area in a varied histogram.
- #135Find sliding-window maximumsInterview-LevelPremium
Return the maximum from every width-three sliding window.
- #136Count required meeting roomsInterview-LevelPremium
Find how many rooms are needed so no meeting is delayed.