[Leet Code] Design a Stack With Increment Operation

Leetcode: https://leetcode.com/problems/design-a-stack-with-increment-operation/

Problem:

Design a stack which supports the following operations.

Implement the CustomStack class:

  • CustomStack(int maxSize) Initializes the object with maxSize which is the maximum number of elements in the stack or do nothing if the stack reached the maxSize.
  • void push(int x) Adds x to the top of the stack if the stack hasn't reached the maxSize.