Adding Stack with Top Values
Problem statement
Implement a stack that starts empty and processes the commands in operations:
push v: add integervto the top.pop: remove the top.inc i v: addvto each of the bottomielements.
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 signed64-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. popis never called on an empty stack.