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.
input = "EVENT u1 c1 0\nEVENT u1 c1 10\nEVENT u1 c2 12\nCOUNT u1 c1 14\nCOUNT u1 c1 16\nEVENT u1 c1 20\nCOUNT u1 c1 25\nCOUNT u1 c2 25" return = ["2","1","2","1"]
At timestamp 16, the event at minute 0 is older than 15 minutes and is not counted.
Timestamps are integer minutes and commands are processed in input order.
Counts are keyed by both user id and chat id.
- Grid Infection Spread Until StablePHONE SCREEN · Seen May 2026
- Grid Infection with Immune Cells Until StablePHONE SCREEN · Seen May 2026
- Infection Spread / Cellular AutomataPHONE SCREEN · Seen May 2026
- Grid Infection with Recovery After D DaysPHONE SCREEN · Seen May 2026
- ChatApp with BotsPHONE SCREEN · Seen May 2026
- IP Address to CIDR BlocksPHONE SCREEN · Seen May 2026
- Count Valid SequencesSeen Jan 2025
- Maximize The HitsSeen Sep 2024
public String[] solveChatEventCounts(String input) {
// write your code here
}