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.

EasyTechnical
50 practiced

Compare a contiguous array (or dynamic array) with a singly linked list for random access, insertion at the head, insertion at the tail, insertion in the middle given a pointer, and iteration. Give the cost of each and say which you would choose for a workload with frequent inserts and occasional reads.

MediumTechnical
51 practiced

Given a singly linked list, detect whether it has a cycle and, if it does, return the length of the cycle. Explain the time and space cost.

HardTechnical
36 practiced

Given a singly linked list, rearrange it so that nodes at indices 0, k, 2k, ... come first, then indices 1, k+1, 2k+1, ... and so on, preserving relative order within each group, in place. For k = 2 this is the odd/even list problem.

MediumTechnical
45 practiced

Simulate a round-robin scheduler: given tasks as (id, duration) pairs and a time quantum q, return each task's finish time in completion order. Explain which structure you use for the ready queue.

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.

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.