Best solution using Prefix sum
Approach
Use a list to store prefix products.
If zero is added, reset the list since all products before it become zero.
For getProduct(k), use division to retr

# Approach
 - Use a list to store prefix products.
 - If zero is added, reset the list since all products before it become zero.
- For `getProduct(k)`, use division to retrieve the product efficiently.

# Complexity
- `add(num)`: O(1), appending to a list.
- `getProduct(k)`: O(1), retrieving and dividing values from the list.

# Code
```
class ProductOfNumbers:
    def __init__(self):
        self.stream=[]

    def add(self, num: int) -> None:
        if num==0:
            self.stream=[]
        elif self.stream==[]:
            self.stream.append(num)
        else:
            self.stream.append(num*self.stream[-1])
        
    def getProduct(self, k: int) -> int:
        n=len(self.stream)
        if n<k:
            return 0
        elif n==k:
            return self.stream[-1]
        else:
            return self.stream[-1]//self.stream[-1-k]
```





['Array', 'Math', 'Design', 'Prefix Sum', 'Python3']