Apple backend engineer interviews typically focus on APIs, databases, system design, concurrency, caching, and data structures.
No verified questions yet for Apple.
MessageQueue with the following methods:def __init__(self): - Initializes the messaging queue.def send(self, message: str) -> None: - Sends a new message to the queue.def receive(self) -> str: - Receives the oldest message from the queue, returning it.def size(self) -> int: - Returns the current number of messages in the queue.Example 1:mq = MessageQueue() followed by mq.send('Hello')Nonemq.receive() after the previous send'Hello''Hello', is returned.Constraints:1 <= message.length <= 1001 <= number of messages <= 10^4RateLimiter that provides the following methods:def __init__(self, limit: int, time_window: int): - Initializes the rate limiter with a specified request limit and time window.def request(self, user_id: str) -> bool: - Determines if a request from user_id should be allowed based on current limits.def cleanup(self): - Cleans up expired requests from the records.Example 1:limiter = RateLimiter(5, 10) followed by limiter.request('user1')Trueuser1 is accepted.Example 2:limiter.request('user1', 5) five timesFalse1 <= limit <= 1001 <= time_window <= 601 <= Number of Requests <= 10^4Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free