Short Prefix Solution:  O(1) for add and getProduct
Complexity

Time complexity:
Each add => O(1)
Each getProduct => O(1)
Mixed n operations of add & getProduct => O(n)


Space complexity:
Worst case O(n), while
# Complexity
- Time complexity:
Each `add` => $$O(1)$$
Each `getProduct` => $$O(1)$$
Mixed `n` operations of `add` & `getProduct` => $$O(n)$$

- Space complexity:
Worst case $$O(n)$$, while consistently adding `0`s ensures the space complexity remains $$O(1)$$.

# Code
```typescript []
class ProductOfNumbers {
    private prfx: number[] = [1];

    add = (num: number) => !num ? this.prfx = [1] :
        this.prfx.push(num * this.prfx.at(-1)!);

    getProduct = (k: number) => k >= this.prfx.length ? 0 :
        this.prfx.at(-1)! / this.prfx.at(-k - 1)!;
}
```
```javascript []
class ProductOfNumbers {
    constructor() { this.prfx = [1]; }

    add = (num) => !num ? this.prfx = [1] :
        this.prfx.push(num * this.prfx.at(-1));

    getProduct = (k) => k >= this.prfx.length ? 0 :
        this.prfx.at(-1) / this.prfx.at(-k - 1);
}
```
['Array', 'Math', 'Dynamic Programming', 'Design', 'Brainteaser', 'Data Stream', 'Prefix Sum', 'TypeScript', 'JavaScript']