Google / Amazon / Uber Interview Question — LeetCode 1352

Y Tech
2 min readJan 30, 2022

In this post, we are going to discuss leetcode 1352 — Product of the Last K Numbers, which is recently asked in Google, Uber, and Amazon interviews.

Problem Analysis

Design an algorithm that accepts a stream of integers and retrieves the product of the last k integers of the stream.

Implement the ProductOfNumbers class:
1.
ProductOfNumbers() Initializes the object with an empty stream.
2.
void add(int num) Appends the integer num to the stream.
3.
int getProduct(int k)

--

--