EASY - Prefix Multiple
Prefix Product
If array is empty then add num
Else take last numbers and multiple last and current and add to array
For getiing product take divide last numbers
**Prefix Product**

1. If array is empty then add num
2. Else take last numbers and multiple last and current and add to array
3. For getiing product take divide last numbers and index from array

# Complexity
- Time complexity: O(1) - both method
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(n) - class
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```kotlin []
class ProductOfNumbers() {

    private val product = mutableListOf<Int>()
    
    fun add(num: Int) {
        when {
            num == 0 -> product.clear()
            product.isEmpty() -> product.add(num)
            else -> product.add(product.last() * num)
        }
    }

    fun getProduct(k: Int): Int {
        return when {
            k > product.size -> 0
            k == product.size -> product.last()
            else -> product.last() / product[product.size - k - 1]
        }
    }

}

/**
 * Your ProductOfNumbers object will be instantiated and called as such:
 * var obj = ProductOfNumbers()
 * obj.add(num)
 * var param_2 = obj.getProduct(k)
 */
```
['Kotlin']