Chat Event Counts in Recent Window
Complete the function below. The function receives the full standard input as a single string and returns the exact standard output lines for a chat-event tracker.
Problem
Implement two operations for tracking chat events:
processEvent(userId, chatId, timestamp): record thatuserIdhad an event inchatIdattimestamp.getCount(userId, chatId, timestamp): return how many events for that exact(userId, chatId)pair occurred in the last 15 minutes, inclusive of the query timestamp and exclusive of events older thantimestamp - 15minutes.
In this command-based version, each line is either EVENT userId chatId timestamp or COUNT userId chatId timestamp. Return one output line for each COUNT command.
Complete solveChatEventCounts. It has one parameter, String input, containing newline-separated commands. Return the stdout payload as an array of lines, without trailing newline characters.
1Example 1
At timestamp 16, the event at minute 0 is older than 15 minutes and is not counted.
Constraints
Limits and guarantees your solution can rely on.
Timestamps are integer minutes and commands are processed in input order.
Counts are keyed by both user id and chat id.