You're given a log stream of a chat application.
Every log entry has the following fields:- timestamp: long – the number of seconds that have elapsed since 1970-01-01.
- sender: string – username of the sender
- receiver: string – username of the receiver
- message_text: string – the message payloadWe want to implement a log stream processor which supports two methods:- RegisterEvent(timestamp,
sender_username,
receiver_username,
message_text)
- registers the event that the message have been sent- GetMostActiveUser()
- Returns the username with the largest number of conversations.
- We count any amount of messages exchanged between two unique users as a single conversation.
A conversation is defined as a unique unordered pair of users.
Messages between A and B count once, regardless of direction or frequency.
You must:
- Track unique user pairs
- Maintain per-user conversation counts
- Efficiently return the max user
This problem tests whether you can design a streaming data structure that tracks unique user pairs as single conversations and efficiently return the user with the most conversations in real time.