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
49 practiced

Design a stack that supports push, pop, top and retrieving the minimum element, all in O(1) time. Show one approach with extra storage, then explain how to get the minimum with only O(1) extra space.

EasyTechnical
50 practiced

Implement a singly linked list from scratch with a Node class and operations to append, prepend, find a value and delete a value, plus a way to dump the contents for testing. Walk through how each operation behaves on an empty list, a single-node list and the tail, and state the cost of each.

MediumTechnical
44 practiced

Implement a queue using two stacks with amortized O(1) enqueue and dequeue. Explain what a worst-case single dequeue looks like and why the amortized cost is still constant.

EasyTechnical
42 practiced

Detect whether a singly linked list contains a cycle using O(1) extra space. Explain why your method terminates and why it must find the cycle if one exists.

EasyTechnical
48 practiced

Implement a stack on top of a dynamic array with push, pop, peek, is_empty and size. Push and pop must be O(1) amortized, and pop on an empty stack must raise a clear error. Also show how you would support a fixed maximum capacity.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.