Suffix products with last zero index. T:90%
Intuition\nKeep track of suffix products since the last zero. \nIf k is greater than or equal to the number of elements since the last zero, zero is the answer.
# Intuition\nKeep track of suffix products since the last zero. \nIf k is greater than or equal to the number of elements since the last zero, zero is the answer. \nElse it\'s the product of entire list divided by the value at k+1 element in the list, from the end. \n\n# Complexity\n- Time complexity:\n $$O(n)$$ \n\n- Space complexity:\n $$O(n)$$ \n\n# Code\n```\nclass ProductOfNumbers:\n\n    def __init__(self):\n        self.ll = [1]\n        \n\n    def add(self, num: int) -> None:\n        if num == 0:\n            self.ll = [1]\n        else: \n            self.ll.append(self.ll[-1] * num)\n        \n\n    def getProduct(self, k: int) -> int:\n        if k >= len(self.ll):\n            return 0\n        return self.ll[-1] // self.ll[-k-1]\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']