All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : July 06, 2024
Last updated : July 06, 2024
Related Topics : Array, Stack, Design
Acceptance Rate : 80.59 %
On Day 39 of my grind, 8:35PM PST, this question was done. Simple one to end off this sprint. :)
class CustomStack:
def __init__(self, maxSize: int):
self.stk = []
self.maxx = maxSize
def push(self, x: int) -> None:
if len(self.stk) >= self.maxx :
return
self.stk.append(x)
def pop(self) -> int:
if not self.stk :
return -1
return self.stk.pop()
def increment(self, k: int, val: int) -> None:
for i in range(min(k, len(self.stk))) :
self.stk[i] += val
# Your CustomStack object will be instantiated and called as such:
# obj = CustomStack(maxSize)
# obj.push(x)
# param_2 = obj.pop()
# obj.increment(k,val)