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)&nbsp;Adds x to the top of the stack if the stack hasn't reached the maxSize.
	int pop()&nbsp;Pops and returns the top of stack or -1 if the stack is empty.
	void inc(int k, int val) Increments the bottom k elements of the stack by val. If there are less than k elements in the stack, just increment all the elements in the stack.


&nbsp;
Example 1:

Input
["CustomStack","push","push","pop","push","push","push","increment","increment","pop","pop","pop","pop"]
[[3],[1],[2],[],[2],[3],[4],[5,100],[2,100],[],[],[],[]]
Output
[null,null,null,2,null,null,null,null,null,103,202,201,-1]
Explanation
CustomStack customStack = new CustomStack(3); // Stack is Empty []
customStack.push(1);                          // stack becomes [1]
customStack.push(2);                          // stack becomes [1, 2]
customStack.pop();                            // return 2 --&gt; Return top of the stack 2, stack becomes [1]
customStack.push(2);                          // stack becomes [1, 2]
customStack.push(3);                          // stack becomes [1, 2, 3]
customStack.push(4);                          // stack still [1, 2, 3], Don't add another elements as size is 4
customStack.increment(5, 100);                // stack becomes [101, 102, 103]
customStack.increment(2, 100);                // stack becomes [201, 202, 103]
customStack.pop();                            // return 103 --&gt; Return top of the stack 103, stack becomes [201, 202]
customStack.pop();                            // return 202 --&gt; Return top of the stack 102, stack becomes [201]
customStack.pop();                            // return 201 --&gt; Return top of the stack 101, stack becomes []
customStack.pop();                            // return -1 --&gt; Stack is empty return -1.


&nbsp;
Constraints:


	1 &lt;= maxSize &lt;= 1000
	1 &lt;= x &lt;= 1000
	1 &lt;= k &lt;= 1000
	0 &lt;= val &lt;= 100
	At most&nbsp;1000&nbsp;calls will be made to each method of increment, push and pop each separately.


	class CustomStack:

		def __init__(self, maxSize: int):
			self.size = maxSize
			self.stack = []

		def push(self, x: int) -> None:
			if self.size > len(self.stack):
				self.stack.append(x)

		def pop(self) -> int:
			if self.stack:
				return self.stack.pop()
			return -1

		def increment(self, k: int, val: int) -> None:
			len_stack = len(self.stack)

			if len_stack < k:
				self.stack[:] = [i + val for i in self.stack]
				return

			for i in range(k):
				self.stack[i] += val
class CustomStack {

    int[] stack;
    int top;

    public CustomStack(int maxSize) {

        //intialise the stack and the top
         stack= new int[maxSize];
        top=-1;
    }

    public void push(int x) {

        // if the stack is full just skip
        if( top==stack.length-1) return;

        //add to the stack
        top++;
        stack[top]=x;
    }

    public int pop() {

        //if stack is empty return -1
        if( top==-1) return -1;

        //remove/pop the top element
        top--;
        return stack[top+1];

    }

    public void increment(int k, int val) {

        //got to increment the min of the elements present in the stack and k
        int n= Math.min(top+1,k);

        for( int i=0; i<n ; i++){
            stack[i]+=val;
        }

    }
}
class CustomStack {
    int *data;
    int nextIndex;
    int capacity;
public:
    CustomStack(int maxSize) {
        data = new int[maxSize];
        nextIndex = 0;
        capacity = maxSize;
    }

    void push(int x) {
        if(nextIndex == capacity){
            return;
        }
        data[nextIndex] = x;
        nextIndex++;
    }

    int pop() {
        if(nextIndex == 0){
            return -1;
        }
        int temp = data[nextIndex-1];
        nextIndex--;
        return temp;
    }

    void increment(int k, int val) {
        //loop will run upto nextIndex if k >= nextIndex else runt upto k only
        int n = (k >= nextIndex) ? nextIndex : k;
        for(int i = 0; i < n; i++){
            data[i] = data[i] + val;
        }
    }
};
var CustomStack = function(maxSize) {
    this.stack = new Array(maxSize).fill(-1);
    this.maxSize = maxSize;
    this.size = 0;
};

CustomStack.prototype.push = function(x) {
    if(this.size < this.maxSize){
        this.stack[this.size] = x;
        this.size++;
    }
};

CustomStack.prototype.pop = function() {
    if(this.size > 0){
        this.size--;
        return this.stack[this.size];
    }
    return -1;
};

CustomStack.prototype.increment = function(k, val) {
    let count = k >= this.size ? this.size-1 : k-1;

    while(count >= 0){
        this.stack[count] += val;
        count--;
    }
};
Design a Stack With Increment Operation