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.

MediumTechnical
46 practiced

Explain how sentinel (dummy) head/tail nodes simplify linked-list code. Show example scenarios for insertion and deletion where a dummy node removes special-casing of head/tail handling, and discuss any downsides and memory overhead of this approach.

EasyTechnical
47 practiced

Write a C function void delete_first(struct Node** head, int value) that deletes the first node with val == value from a singly linked list defined as struct Node { int val; struct Node* next; };. The function should correctly handle deleting the head node and free the removed node's memory. Use a dummy (sentinel) node to simplify edge cases and explain why the dummy node helps.

MediumTechnical
48 practiced

Given heads of two singly linked lists, write a C/C++ function ListNode* intersection_node(ListNode* headA, ListNode* headB) that returns the node where the two lists intersect (by pointer), or NULL if they do not. Achieve O(m+n) time and O(1) extra space. Explain the 'pointer switching' technique and its correctness.

HardTechnical
41 practiced

Implement an in-place algorithm in C or C++ to determine whether a singly linked list is a palindrome in O(n) time and O(1) extra space. You may modify the list during processing but must restore it before returning the result. Provide clear steps or code and explain why the list must be restored in long-running systems.

HardTechnical
48 practiced

Implement a function ListNode* reverse_k_group(ListNode* head, int k) in C++ that reverses the nodes of a linked list k at a time and returns the modified list. You must do this in-place with O(1) extra memory and leave the remainder as-is if fewer than k nodes remain at the end. Provide clear pointer manipulation code or high-level pseudocode.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.