Prefix multiplication
IntuitionWe want to return the product
It will be easy when we add the product in list rather then adding the elementApproachAppending the product to list by mu
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
We want to return the product
It will be easy when we add the product in list rather then adding the element
# Approach
<!-- Describe your approach to solving the problem. -->
Appending the product to list by multiplying with last element
If the product is zero just overwrite the arr with 1 element
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
Adding and product done in a single operation by using control statements
So,the time complexity is **O(N)**
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
We just create an array in add function
So,the space complexity is **O(N)**
# Code
```python []
class ProductOfNumbers(object):

    def __init__(self):
       self.prefix=[1] 

    def add(self, num):
        if num==0:
            self.prefix=[1] 
        else:
            self.prefix.append(num*self.prefix[-1])

    def getProduct(self, k):
        if k>=len(self.prefix):
            return 0
        return self.prefix[-1]//self.prefix[-1-k]



```
['Python']