Skip to content
Tech Interview Prep home
Technical interview guide

Stacks

LIFO ordering for tracking nested structure — matching parentheses, undo history, and monotonic sequences.

Read
42 min
Practice MCQs
25
Interview QA
25
Edition
v6
Editorial status
Reviewed

Scope: Language-neutral, with container costs and recursion limits cited from CPython 3.14, the C++ standard containers, and java.util as of Java 21.

Interview QA

Treat each question like a live interview question: answer out loud first (structure, assumptions, tradeoffs), then open the model answer to spot gaps and rehearse a tighter follow-up.

Curated: · Written: · Reviewed:

QA-1

Walk through balanced-bracket validation, including where engineers most often get it wrong.

QA-2

Describe the monotonic stack and the evidence you would collect before relying on it.

QA-3

Explain the stack contract and how it changes a production decision.

QA-4

How do you implement a stack with push, pop, and min/max operations in O(1) time and space complexity?

QA-5

How would you reason about the stack invariant in a system you own?

QA-6

A teammate proposes a design that hinges on storing indices rather than values. How do you evaluate it?

QA-7

Where does elements left on the stack matter, and where is it irrelevant?

QA-8

Teach largest rectangle in a histogram to an engineer who has only seen it as a rule of thumb.

QA-9

How do sentinel elements simplify edge case handling and loop terminations in monotonic stack algorithms?

QA-10

How do you implement expression evaluation for infix notation with operator precedence using two stacks?

QA-11

What would you measure before treating infix to postfix conversion as settled?

QA-12

How does the call stack as a data structure change if the workload grows by two orders of magnitude?

QA-13

How do you implement an iterative tree traversal using an explicit stack, and what are the trade-offs versus recursion in production systems?

QA-14

When would you refuse a design because of tail calls?

QA-15

How would you explain iterative tree traversal without using the usual slogan?

QA-16

What failure would you inject to check a team's understanding of the two-stack queue?

QA-17

How should on-call treat an alert that names the constant-time minimum stack as the cause?

QA-18

What belongs in a runbook section on undo and history, and what does not?

QA-19

How would you review a pull request whose risk is stack-based backtracking state?

QA-20

What trade-off does stack versus queue force that a junior answer usually skips?

QA-21

How would you brief product on why array-backed versus linked stacks delays a ship date?

QA-22

What is the smallest experiment that would change your mind about stack overflow as a security boundary?

QA-23

How does capacity and memory bounds interact with rollback, and where do people ignore that?

QA-24

What would you ask a candidate who recites amortised analysis of stack algorithms but cannot apply it?

QA-25

How would you document recognising a stack problem so the next owner can operate it?