Reported interview periodOct 2025
Thread-Safe Channel Chat
Implement an in-memory chat service in which users subscribe to channels, messages are appended to channel histories, and users read messages from their current subscriptions.
Practice focusRequirements - Methods may run concurrently and shared state must be protected explicitly. - Sending appends [channel id, user id, message] even if the sender is not subscribed. - Reading concatenates histories for the user's current subscriptions in sorted channel-id order; each channel remains in send order. - Unsubscribing hides that channel's history from subsequent reads. - Repeated subscribe or unsubscribe operations should be idempotent. - Define the consistency point of each operation and avoid exposing partially written messages.…