C++ Accepted prefix product
class ProductOfNumbers {\npublic:\n        vector ans;\n        int brk=-1,i=0;\n    ProductOfNumbers() {\n        \n    }\n    \n    void add(int num) {\n     
class ProductOfNumbers {\npublic:\n        vector<int> ans;\n        int brk=-1,i=0;\n    ProductOfNumbers() {\n        \n    }\n    \n    void add(int num) {\n        if(num==0)\n        {\n                brk=i;\n                ans.push_back(1);\n                i++;\n                return;\n        }\n            else\n            {\n                    if(ans.size()==0)\n                            ans.push_back(num);\n                    else \n                            ans.push_back(num*ans[i-1]);\n                    i++;\n            }\n    }\n    \n    int getProduct(int k) {\n            int realbrk=i-brk;\n            if(k>=realbrk)\n                    return 0;\n            else\n            {\n                  if(k==ans.size())  \n                          return ans[ans.size()-1];\n                    else\n                            return (ans[ans.size()-1]/ans[ans.size()-k-1]);\n            }\n    }\n};
['C']