Easy to understand || Python || python3
IntuitionApproachInitialize the list with --> 1
if we use 0 then then whole product can be get 0if num==0 then again initialize with --> 1
else append to the li
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
Initialize the list with --> 1
if we use 0 then then whole product can be get 0

if num==0 then again initialize with --> 1
else append to the list with product of num and last element of list
because we need to form prefix sum, which reduces the time complexity

if k becomes greater or equal to len of l, return 0 -->as we cannot form product more than len(l) elements
else return last element and divide with element of index k from last 
as it was prefix sum so it removes the extra values



<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
- O(1)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
- O(N)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class ProductOfNumbers:

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

    def add(self, num: int) -> None:
        if num==0:
            self.l=[1]
        else:
            self.l.append(self.l[-1]*num)
        

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


# Your ProductOfNumbers object will be instantiated and called as such:
# obj = ProductOfNumbers()
# obj.add(num)
# param_2 = obj.getProduct(k)
```
['Python', 'Python3']