Easy Approch || O(1) || Ruby Solution
Approachfirstly try to solve this on pen paper then you'll get that we dont need to add element but the product of last 2 elements and we've to reset array's la
# Approach
firstly try to solve this on pen paper then you'll get that we dont need to add element but the product of last 2 elements and we've to reset array's last element into 1 so when we get 0 as a element for pushing in array so that it'll be easy for us for multiplication purpose and then use that formula

(Last element which is the product of last 2 numbers) / ((k-1)th element of array)

# Complexity
- Time complexity:
O(1)
- Space complexity:
O(n)
# Code
```ruby []
class ProductOfNumbers
    def initialize()
        @a = [1]
    end

    def add(num)
        if num == 0
            @a = [1]
        else
            @a.push(@a[-1] * num)
        end
    end

    def get_product(k)
        return 0 if k >= @a.length
        @a[-1] / @a[@a.length - 1 - k]
    end
end
```
['Ruby']