Amazon | Senior SDE | Virtual Interview | April 2020
Anonymous User
1331

Questions asked in 1 hour virtual interview with Amazon. Took me by surprise. No leetcode.

I). We have a class(Repeater) which listens to an input stream of integers at the rate of 1 integer per sec. (integer range will always be between 1-1000). We have two functions inputInt and poke

  • input(int i) - listens to each integer coming from input stream.
  • poke() - When poked, output the latest/recent/last 100,000 integers the system saw, in a sorted order
    Design/implement for optimal memory and performance
 -  eg, input - 3,5,1,7,0,1,8,3, ..
 -   Poked output - 0,1,1,3,3,5,7,8..
class Repeater {
	public void inputInt(int i) {}
	public List<Integer> poke() {}
}

Implement the below methods such that the time complexity of each method is efficient. You can use extra space if that reduces the time complexity.

II). Implement all required classes and methods to achieve the following:

  • Amazon and VISA has a contract such that Amazon can send 10,000 transaction requests to VISA in the last 2 seconds. This time window is rolling time-window.
  • If there are more than 10,000 valid requests(valid since they are within the 2 sec rolling window), then you should efficiently handle them such that these requests are not dropped/rejected.
  • You can assume that batch api's are already implemented to take care of sending 10,000 requests. You just need to implement the backend logic so that Amazon and VISA can process these transactions that satisfy the contract between these two companies.
Comments (5)