Amazon backend engineer interviews typically focus on APIs, databases, system design, concurrency, caching, and data structures.
No verified questions yet for Amazon.
MessageQueue class that supports the following methods:void send(string message): to add a new message to the queue.string receive(): to retrieve and remove a message from the front of the queue, returns an empty string if the queue is empty.int size(): returns the number of messages currently in the queue.Example 1: MessageQueue mq = new MessageQueue();mq.send("msg1");null mq.send("msg2");null mq.receive();"msg1" mq.size();1Constraints:10^4.RateLimiter class that controls requests to an API. It should allow a maximum of limit requests per second. Implement the following methods:bool allowRequest(string userId): returns true if the request should be allowed.int getRequestCount(string userId): returns the number of requests made by the user in the last second.Example 1: RateLimiter rateLimiter = new RateLimiter(5);rateLimiter.allowRequest("user1");true rateLimiter.allowRequest("user1");...// After 6 calls, the 6th should return falsefalseConstraints:1 <= limit <= 1001 <= userId.length <= 30.Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free