✅💯🔥Simple Code🚀📌|| 🔥✔️Easy to understand🎯 || 🎓🧠Beats 100%🔥|| Beginner friendly💀💯
Tuntun Mosi ko Pranam\nSolution tuntun mosi ki photo ke baad hai. Scroll Down\n\n# Code\njava []\nclass ProductOfNumbers {\n    List<Integer> list;\n    int pre
# Tuntun Mosi ko Pranam\nSolution tuntun mosi ki photo ke baad hai. Scroll Down\n![fd9d3417-20fb-4e19-98fa-3dd39eeedf43_1723794694.932518.png](https://assets.leetcode.com/users/images/a492c0ef-bde0-4447-81e6-2ded326cd877_1724187540.6168394.png)\n# Code\n```java []\nclass ProductOfNumbers {\n    List<Integer> list;\n    int prev;\n    public ProductOfNumbers() {\n        list=new ArrayList<>();\n        prev=1;\n        list.add(1);\n    }\n    \n    public void add(int num) {\n        if(num>0){\n            prev*=num;\n            list.add(prev);\n        }else{\n            list=new ArrayList();\n            list.add(1);\n            prev=1;\n        }\n    }\n    \n    public int getProduct(int k) {\n        int n = list.size();\n        return k<n? prev/list.get(n-1-k):0;\n    }\n}\n\n/**\n * Your ProductOfNumbers object will be instantiated and called as such:\n * ProductOfNumbers obj = new ProductOfNumbers();\n * obj.add(num);\n * int param_2 = obj.getProduct(k);\n */\n```\n![7be995b4-0cf4-4fa3-b48b-8086738ea4ba_1699897744.9062278.jpeg](https://assets.leetcode.com/users/images/fe5117c9-43b1-4ec8-8979-20c4c7f78d98_1721303757.4674635.jpeg)
['Array', 'Math', 'Design', 'Queue', 'C', 'Data Stream', 'Python', 'C++', 'Java', 'JavaScript']