InterviewStack.io LogoInterviewStack.io

Linked Lists, Stacks, and Queues Questions

Pointer-based linear structures: singly and doubly linked lists, stacks, queues, and deques. Covers pointer manipulation, cycle detection, reversal, and using LIFO/FIFO ordering to model traversal, undo, and scheduling problems. Foundational for both interview problems and understanding how higher-level structures are built.

HardTechnical
45 practiced

Implement an algorithm to reverse nodes in a linked list in groups of size k, but now k changes per group (given as an array of group sizes). Write code (Python/C++) that performs these variable-group reversals in-place and discuss correctness and complexity.

EasyTechnical
39 practiced

Describe a circular buffer (ring buffer) for implementing a fixed-capacity queue. Explain how you detect full vs empty, and write enqueue/dequeue pseudo-code in C++ that avoids moving elements and runs in O(1) time.

EasyTechnical
35 practiced

Given two sorted singly linked lists, implement merge_two_sorted_lists(l1, l2) in Python that returns a merged sorted list by reusing node pointers. Implement iteratively in O(n + m) time and O(1) extra space. Show example l1 = 1->3->5 and l2 = 2->4 and resulting list.

MediumTechnical
40 practiced

Explain how monotonic stacks and monotonic queues differ and give two algorithmic problems (one for each) that use them. For each problem, outline how the monotonic data structure leads to an O(n) solution and why brute-force would be slower.

MediumTechnical
44 practiced

Implement reverse_sublist(head, m, n) in Python to reverse nodes in a singly linked list from position m to n inclusive in one pass. Positions are 1-based. Use a dummy node to handle head modifications and achieve O(n) time and O(1) space. Validate inputs and explain pointer updates during reversal.

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.