Design ProductOfNumbers, which receives a stream of integers. add(num) appends num to the stream, and getProduct(k) returns the product of the last k numbers added. You may assume the stream always holds at least k numbers and that every answer fits in a 32-bit integer.
Design ProductOfNumbers, which receives a stream of integers. add(num) appends num to the stream, and getProduct(k) returns the product of the last k numbers added. You may assume the stream always holds at least k numbers and that every answer fits in a 32-bit integer.