C# - Similar to Prefix Sum, use Prefix Product and handle 0 input
When Zero input is encountered, clear the history as the result is always zero beyond current count. \nAlso, similar to prefix Sum array - the difference betwee
When Zero input is encountered, clear the history as the result is always zero beyond current count. \nAlso, similar to prefix Sum array - the difference between the last index and first index - 1 values gives sum in the range, the division gives the product in the range for product prefix array.\n\n```csharp\npublic class ProductOfNumbers\n{\n    readonly private List<int> result;\n    \n    public ProductOfNumbers()\n    {\n        result = new List<int>(){1};    \n    }\n\n    public void Add(int num)\n    {\n        if (num == 0)\n        {\n            result.Clear();\n            result.Add(1);\n        }\n\n        else\n        {\n            result.Add(result[result.Count - 1] * num);           \n        }        \n    }\n\n    public int GetProduct(int k)\n    {\n        if (k < result.Count)\n        {\n            return result[result.Count - 1]/result[result.Count - k - 1];\n        }\n\n        else\n        {\n           return 0;\n        }\n    }\n}\n```
[]