https://leetcode-cn.com/problems/design-a-stack-with-increment-operation/
    [制卡]

    1. class CustomStack {
    2. public arr: number[] = []
    3. public length: number = 0
    4. constructor(maxSize: number) {
    5. this.length = maxSize
    6. }
    7. push(x: number): void {
    8. if (this.arr.length < this.length) {
    9. this.arr.push(x)
    10. }
    11. }
    12. pop(): number {
    13. const item = this.arr.pop()
    14. return item === undefined ? -1 : item
    15. }
    16. increment(k: number, val: number): void {
    17. this.arr = this.arr.map((item,index) => index < k? item + val: item);
    18. }
    19. }