Linked Lists, Stacks, and Queues Questions

Pointer-based linear structures and the classic problems built on them: singly, doubly and circular linked lists (reversal whole, partial and in groups of k, cycle detection and cycle start with fast/slow pointers, intersection, middle and nth-from-end, merging two or k sorted lists, sorting a list, reordering, palindrome check, rotation, partitioning, duplicate removal, deep copy with random pointers, flattening child lists, sentinel nodes), implementing lists in C, C++ and Rust with attention to pointer handling, ownership and cleanup, array versus linked-list trade-offs including cache locality, stacks, queues and deques (array, linked and circular-buffer implementations, ring-buffer full versus empty, queue from two stacks, min stack, round-robin scheduling), monotonic stacks and queues (next greater element, largest rectangle in a histogram, sliding-window maximum), stack-based expression and bracket evaluation (balanced brackets, Reverse Polish Notation, infix to postfix, calculators), and structure-level builds such as an LRU cache from a hash map plus doubly linked list, undo/redo history, and variants like persistent or unrolled lists. Foundational for coding interviews and for understanding how higher-level structures are built. Concurrent and lock-free queues, memory allocators, general graph traversal, heaps and cache-eviction system design are covered elsewhere.

MediumTechnical
65 practiced

Implement a resizable deque on a circular array supporting add and remove at both ends and peeking, in amortized O(1). Describe when and how you grow and shrink the array and how the indices move.

MediumTechnical
35 practiced

Design a task queue that is normally FIFO but allows any queued task to be promoted to the front in O(1), with O(1) enqueue. Explain the data structures you combine and how you would prevent starvation of unpromoted tasks.

EasyTechnical
40 practiced

Return the middle node of a singly linked list in one pass and O(1) space. For an even-length list, say which of the two middle nodes you return and why, and explain how your method lands on it.

MediumTechnical
43 practiced

Given an array, return for each element the first greater element to its right, or -1 if none exists. Aim for O(n) time and explain why the total work is linear.

HardTechnical
35 practiced

You must merge k sorted linked lists where k is in the tens of thousands and N is very large. Compare heap-based merging, pairwise divide-and-conquer and sequential merging on time, extra memory and constant factors, and say which you would use and why.

Unlock Full Question Bank

Get access to all Linked Lists, Stacks, and Queues interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.