(This question is a variation of the LeetCode question 362. Design Hit Counter. If you haven't completed that question yet, it is recommended to solve it first.)
Design a message-event aggregator for a long-running system. Each event identifies a user and a chat and has a timestamp measured in whole seconds. For any user and query timestamp, report the number of recorded events in the trailing window of m seconds. The window is inclusive and equals [timestamp - m + 1, timestamp].
Events for the same user arrive in strictly increasing timestamp order. The system must remain memory-efficient over an indefinite runtime by discarding history that can no longer affect future queries.
Implement the ChatEventAggregator class:
ChatEventAggregator(int m)Initializes the aggregator with the positive window lengthm, measured in seconds.
Ask AI Assistant

Ask AI Assistant
Ask me anything about this coding question!
Test Cases
Input
Output
Expected