FastPrepConstant-Time Minimum Stack
Problems/Constant-Time Minimum Stack

Constant-Time Minimum Stack

LinkedIn logoLinkedIn● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a LinkedIn phone screen. The report names a task like MinStack, where every operation takes constant time. It does not say which variation it was. Here, we use the usual stack that also tracks the minimum, a finite list of operations, and clear rules for what is valid. Our version is about 75% the same as the reported question.

Implement a stack that supports pushing, popping, reading the top value, and reading the smallest value, each in O(1) time.

In this exercise, start with an empty stack and process the valid strings in operations in order:

  • PUSH x: place integer x on top.
  • POP: remove the top value and produce no output.
  • TOP: append the top value to the result without modifying the stack.
  • MIN: append the smallest value currently in the stack to the result without modifying the stack.

Return the integer results of only TOP and MIN, in operation order. Store repeated values as separate stack entries. Every POP, TOP, and MIN is guaranteed to occur while the stack is nonempty. If there are no query operations, return an empty array.

Function

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

Examples

Example 1

operations = ["PUSH -2","PUSH 0","PUSH -3","MIN","POP","TOP","MIN"]return = [-3,0,-2]

The first minimum is -3. After popping it, the top is 0 and the minimum among the remaining values is -2.

Example 2

operations = []return = []

No operations produce no query results.

Example 3

operations = ["PUSH 5","PUSH 5","MIN","POP","MIN"]return = [5,5]

Popping one occurrence of 5 leaves the other occurrence, so both minimum queries return 5.

Constraints

  • For this exercise, assume 0 <= operations.length <= 1000.
  • Every operation is exactly PUSH x, POP, TOP, or MIN; PUSH uses one space and a base-10 integer without a leading plus sign.
  • -10^9 <= x <= 10^9.
  • Every non-push operation has a nonempty stack. The whole sequence must run in O(m) time for m operations, with O(1) work per operation after allocating storage.

More LinkedIn Phone Screen questions

  • Maximum Product of a Contiguous SubarrayPHONE SCREEN · Seen Nov 2026
  • Maximum Sum of a Contiguous SubarrayPHONE SCREEN · Seen Nov 2026
  • Merge Two Sorted ListsPHONE SCREEN · Seen Nov 2026
  • Sqrt(x)PHONE SCREEN · Seen Nov 2026
  • Total Years of Work ExperiencePHONE SCREEN · Seen Nov 2026
  • Sum an Arbitrary-Dimensional ArrayPHONE SCREEN · Seen Oct 2026
  • Known Words Matching Phone DigitsPHONE SCREEN · Seen Oct 2026
  • Inverse-Depth Nested List SumPHONE SCREEN · Seen Oct 2026
  • Valid Number with ExponentsPHONE SCREEN · Seen Oct 2026
  • Sort a Quadratic-Transformed ArrayPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Minimum StackSnowflake · PHONE SCREENSnowflake interview questions
  • Next Taller Building to the RightTemu · PHONE SCREENTemu interview questions
  • Subtract the Next Smaller ValueExpedia · PHONE SCREENExpedia interview questions
  • Largest Rectangle in HistogramByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
  • Generic Stack Operation SequenceArista Networks · PHONE SCREEN · ONSITE INTERVIEWArista Networks interview questions
  • Trapping Rain WaterBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Asteroid CollisionSiemens · PHONE SCREEN
  • Billing Log with Undo and RedoReddit · PHONE SCREENReddit interview questions
  • Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Daily TemperaturesCARS24 · PHONE SCREEN

LinkedIn interview experiences

  • LinkedIn Senior MLE Interview Questions: 1 Experience
  • LinkedIn Staff AI Engineer Phone Screens: 1 Experience
  • LinkedIn Experienced MLE Onsite: 1 Experience
  • LinkedIn Coding with AI Interview: 4 Experiences
  • LinkedIn Experienced Infrastructure SWE Onsite: 1 Experience
All LinkedIn interview questionsSee LinkedIn hiring insights
Saved
class Solution {
    public int[] runMinStack(String[] operations) {
        // Write your code here.
    }

}
Checking account…