O(1) Human Readable JavaScript (original prototype plus ES6 class Syntax)
This is the original answer with memoization;\n\nvar ProductOfNumbers = function() {\n    this.numsArr = [1];\n};\n\nProductOfNumbers.prototype.add = function(n
This is the original answer with memoization;\n```\nvar ProductOfNumbers = function() {\n    this.numsArr = [1];\n};\n\nProductOfNumbers.prototype.add = function(num) {\n        if(!num) {\n            this.numsArr = [1];\n        } else {\n            this.numsArr.unshift(num * (this.numsArr[0] || 1));\n        }\n};\n\n\nProductOfNumbers.prototype.getProduct = function(k) {\n    return (this.numsArr[0] / this.numsArr[k]) || 0;\n};\n```\n\nHere is ES6 class syntax if interview needed(sadly, leetcode doesn\'t support):\n\n```\nclass ProductOfNumbers {\n    constructor(){\n        this.numsArr = [1];\n    }\n    add(num) {\n        if(!num) {\n            this.numsArr = [1];\n        } else {\n            this.numsArr.unshift(num * (this.numsArr[0] || 1));\n        }\n    }\n    getProduct(k) {\n        return (this.numsArr[0] / this.numsArr[k]) || 0;\n    }\n}\n```\n
['Dynamic Programming', 'Memoization', 'JavaScript']