Google backend engineer interviews typically focus on APIs, databases, system design, concurrency, caching, and data structures.
No verified questions yet for Google.
MessageQueue class that allows enqueuing and dequeuing messages, ensuring that all messages are processed in FIFO order.class MessageQueue:def __init__(self): — initializes the message queue.def enqueue(self, message: str) -> None: — adds a message to the queue.def dequeue(self) -> str: — removes and returns the oldest message from the queue. If the queue is empty, raises an exception.msg_queue = MessageQueue(); msg_queue.enqueue('Hello'); msg_queue.enqueue('World'); msg_queue.dequeue()'Hello'RateLimiter class which limits the number of API requests per second.class RateLimiter:def __init__(self, requests_per_second: int): — initializes the rate limiter with the specified maximum requests per second.def allow_request(self, user_id: str) -> bool: — returns True if the request is allowed according to the rate limit, otherwise False.def reset(self, user_id: str) -> None: — resets the request count for a specific user.RateLimiter(2); rate_limiter.allow_request('user1')Truerate_limiter.allow_request('user1')Truerate_limiter.allow_request('user1')Falserate_limiter.reset('user1')1 <= requests_per_second <= 100Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free