Max size stack increment

Write codeMedium20 min

Your task

Design a stack with a maximum size that also supports a bulk increment. Process ops: ['push', x] pushes x only if the stack has fewer than maxSize elements (otherwise no-op); ['pop'] removes and returns the top, or -1 if empty; ['increment', k, val] adds val to the bottom-most k elements (or all elements if there are fewer than k). Return the list of pop results, in order.

Examples

custom_stack(maxSize: int, ops: list[list]) -> list[int]
Example 1
Inputcustom_stack(3, [["push", 1], ["push", 2], ["pop"], ["push", 2], ["push", 3], ["push", 4], ["increment", 5, 100], ["increment", 2, 100], ["pop"], ["pop"], ["pop"], ["pop"]])
Output[2, 103, 202, 201, -1]