FastPrepAdding Stack with Top Values
Problems/Adding Stack with Top Values

Adding Stack with Top Values

IMC Trading logoIMC Trading● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an IMC Trading new grad online assessment. Our version is about 99% the same as the original screenshots. It reports the top after every operation. The stack-sum variant that was reported separately is a different exercise.

Implement a stack that starts empty and processes the commands in operations:

  • push v: add integer v to the top.
  • pop: remove the top.
  • inc i v: add v to each of the bottom i elements.

Return one string per command: the current top as a decimal integer, or EMPTY if the stack is empty. Each command should take constant amortized time. Use signed 64-bit arithmetic for stack values.

Function

superStack(operations: String[]) → String[]

Examples

Example 1

operations = ["push 4","push 5","inc 2 1","pop","pop"]return = ["4","5","6","5","EMPTY"]

Report the current top after each operation, including EMPTY when the stack becomes empty.

Example 2

operations = ["push 2","push 8","inc 1 3","pop","push -1","pop","pop"]return = ["2","8","8","5","-1","5","EMPTY"]

Report the current top after each operation, including EMPTY when the stack becomes empty.

Constraints

  • 1 <= operations.length <= 2 * 10^5
  • -10^9 <= v <= 10^9
  • For inc i v, 1 <= i <= current stack size.
  • pop is never called on an empty stack.

More IMC Trading Online Assessment questions

  • Earliest Meeting Start on a 24-Hour ClockOA · Seen Nov 2026
  • Grid Paths with Override PassesOA · Seen Oct 2026
  • Weighted LFU CacheOA · Seen Sep 2026
  • Rock JumpingOA · Seen Aug 2026
  • Stack Batch RemovalOA · Seen Aug 2026
  • Chain of CommandOA · Seen Aug 2026
  • Choose ContainersOA · Seen Aug 2026
  • Sub-matrix SumsOA · Seen Jul 2026
  • Sub-matrix SumsOA · Seen Jul 2026
  • Can Every Package Fit in a BoxOA · Seen Jul 2026

Similar questions at other companies

  • Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Sum of Subarray MinimumsNVIDIA · OANVIDIA interview questions
  • Shopkeeper Final Price SummaryMicrosoft · OAMicrosoft interview questions
  • Nested Recipe Blocks (Game Adaptation)Roblox · OARoblox interview questions
  • Maximum Capped Histogram Area After One RemovalMyntra · OAMyntra interview questions
  • Steps to the Next Higher Value in a CircleRippling · OARippling interview questions
  • Shopkeeper Final PriceUber · OAUber interview questions
  • Predict AnswerAmazon · OA
  • Retention Policy CollisionBox · OABox interview questions
  • Longest Prefix-Valid Binary SubarrayHackerRank · OAHackerRank interview questions

Interview reports that mention this question

  • IMC Trading OA: What It Tests (2026)
  • IMC Trading SWE OA and Video: 18 Experiences (Part 3 of 3)
  • IMC Trading SWE OA Questions: 22 Experiences (Part 2 of 3)
  • IMC SWE New Grad OA and Interviews: 58 Experiences (Part 1 of 3)
All IMC Trading interview questionsSee IMC Trading hiring insights
Saved
class Solution {
    public String[] superStack(String[] operations) {
        // Write your solution here.
    }
}
Checking account…