Use sum array and array reset, with detailed explanation and comment
keyPoint:\n\nit adds complexity when added num is 0:\n1, just reset the sum - array.\n2, You don\'t have to worry about the k > real length, since it is said: \
keyPoint:\n\nit adds complexity when added num is 0:\n1, just reset the sum - array.\n2, You don\'t have to worry about the k > real length, since it is said: \n"You can assume that always the current list has at least k numbers."\n\n```\nclass ProductOfNumbers {\n    \n    private List<Integer> sum;\n    private int l;\n    private int last;\n\n    public ProductOfNumbers() {\n        add(0); //creat dummy head, since You can assume that always the current list has at least k numbers.\n    }\n    \n    public void add(int num) {\n        if (num == 0) {\n            sum = new ArrayList<>();  // sum array;\n            sum.add(1);   // dummy head;\n            l = 1;   //length of current array;\n            last = 1;  // last of sum array, aka, the overrral sum of all added nums after last 0;\n        } else {\n            last *= num;\n            sum.add(last);\n            l++;\n        }\n    }\n    \n    public int getProduct(int k) {\n        return k < l ? last / sum.get(l - k - 1) : 0;\n    }\n}\n```\n\nThanks lee215: https://leetcode.com/problems/product-of-the-last-k-numbers/discuss/510260/JavaC%2B%2BPython-Prefix-Product
[]