87% beats. very easy
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass ProductOfNumbers:\n\n    def __init__(self):\n        self.products = []\n        self.product = 1\n        \n\n    def add(self, num: int) -> None:\n        if num:\n            self.product *= num\n            self.products.append(self.product)\n        else:\n            self.products = []\n            self.product =  1\n\n    def getProduct(self, k: int) -> int:\n        if len(self.products)< k:\n            return 0\n        elif k == len(self.products):\n            return self.product\n        else:\n            return int(self.products[-1]/self.products[-1-k])\n        \n\n\n# Your ProductOfNumbers object will be instantiated and called as such:\n# obj = ProductOfNumbers()\n# obj.add(num)\n# param_2 = obj.getProduct(k)\n```
['Python3']