FastPrepMin Stack
Problems/Min Stack

Min Stack

Expedia logoExpedia● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interviewers asked for a min stack. One candidate wrote that they gave 2 ways: 1. use two stacks, 2. keep one global min.

The reports give only the name and those two methods. They do not give the operations, the input format, examples, or limits. Here, you get the calls as a list of strings and return one output for each pop, top, and getMin. Values are 32-bit integers, and no call reads or pops an empty stack. These are our choices, not from the reports.

Our version is about 85% the same as the reported questions.

Build a stack that can also tell you its smallest value. The stack starts empty, and you get the calls in order as the list of strings operations:

  • push x puts the integer x on top. It gives no output.
  • pop removes the top value and outputs it.
  • top outputs the top value and leaves it in place.
  • getMin outputs the smallest value in the stack and leaves the stack as it is.

Return an array with one output for each pop, top, and getMin, in the order they ran. If there are only pushes, return an empty array.

Aim for constant time per operation.

Function

processMinStack(operations: String[]) → int[]

Examples

Example 1

operations = ["push 5","push 3","push 8","getMin","top","pop","getMin"]return = [3,8,8,3]

After the three pushes, the stack is 5, 3, 8 from bottom to top. The smallest value is 3 and the top is 8. The pop removes 8 and outputs it. The smallest value is still 3. The pushes give no output, so the result has four values.

Example 2

operations = ["push 4","push 2","push 2","pop","getMin","pop","getMin"]return = [2,2,2,4]

The value 2 is in the stack twice. The first pop removes one copy and outputs 2. The other copy is still there, so the smallest value is still 2. The second pop removes that copy and outputs 2. Only 4 is left, so the smallest value is now 4.

Example 3

operations = ["push -2147483648","push 2147483647","getMin","top","pop","getMin"]return = [-2147483648,2147483647,2147483647,-2147483648]

These are the smallest and largest 32-bit values. The smallest value in the stack is -2147483648 and the top is 2147483647. The pop outputs 2147483647, and the smallest value stays the same. The gap between the two values is 2^32 - 1, which does not fit in a 32-bit integer.

Example 4

operations = ["push 1","pop","push 9","getMin"]return = [1,9]

The pop outputs 1 and leaves the stack empty. The next push starts fresh, so the smallest value is 9. The old value 1 no longer counts.

Constraints

  • 1 <= operations.length <= 3 * 10^4
  • Each operation is push x, pop, top, or getMin.
  • x is a 32-bit signed integer, from -2^31 to 2^31 - 1.
  • pop, top, and getMin only run when the stack is not empty.

More Expedia Onsite Interview questions

  • Scramble StringONSITE INTERVIEW · Seen Sep 2026
  • Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
  • Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
  • Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
  • Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
  • Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
  • Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
  • Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
  • Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
  • Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024

Similar questions at other companies

  • KV Store with Nested TransactionsApplied Intuition · PHONE SCREEN · ONSITE INTERVIEWApplied Intuition interview questions
  • Min StackDP World · ONSITE INTERVIEW
  • Code Editor FoldingJane Street · ONSITE INTERVIEWJane Street interview questions
  • Undo and Redo Command HistoryNetflix · ONSITE INTERVIEWNetflix interview questions
  • Min StackMicrosoft · PHONE SCREEN · ONSITE INTERVIEWMicrosoft interview questions
  • Text Document HistoryNotion · PHONE SCREEN · ONSITE INTERVIEWNotion interview questions
  • Equity Price History with O(1) StatisticsBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Nested Transaction Key-Value StorexAI · ONSITE INTERVIEWxAI interview questions
  • Transactional In-Memory RedisHashiCorp · ONSITE INTERVIEWHashiCorp interview questions
  • Key-Value Store with Nested TransactionsRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions

Interview reports that mention this question

  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
  • Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)

Expedia interview experiences

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
  • Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia SWE Intern Final Round: 126 Experiences (Part 1 of 6)
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public int[] processMinStack(String[] operations) {
        // Write your code here.
    }
}
Checking account…