Tap here to switch tabs
Problem
Submissions

Problem: Count Mentions Per User

Try to solve the Count Mentions Per User problem.

Statement

You are given an integer numberOfUsers representing the total number of users, indexed from 00 to numberOfUsers −1- 1.

You are also given an array events of length nn, where events[i] = [eventType, timestamp, mentionsString].

All users are initially online. When a user goes offline, they remain offline for 6060 units of time and automatically return online at timestamp +60+ 60.

There are two types of events:

  1. Message Event: eventType is "MESSAGE"

    • The event occurs at timestamp.

    • mentionsString can take one of the following formats:

      • "ALL": Mentions every user, whether they are online or offline.

      • "HERE": Mentions all users who are currently online.

      • A space separated string of user identifiers formatted as id<number> (for example, "id1 id0"): Mentions the specified users. Each occurrence of an identifier adds 11 mention to that user, regardless of their online status.

  2. Offline Event: eventType is "OFFLINE"

    • The user with ID int(mentionsString) goes offline at timestamp and will be back online at timestamp +60+ 60.

Return an array mentions of length numberOfUsers, where mentions[i] represents the total number of mentions user ii received across all events.

Note: Events might not be sorted by timestamp. If multiple events occur at the same timestamp, all "OFFLINE" events must be processed before any "MESSAGE" events.

Constraints:

  • 1≤1 \leq numberOfUsers ≤100\leq 100

  • 1≤1 \leq events.length ≤100\leq 100

  • events[i].length =3= 3

  • events[i][0] will be one of "MESSAGE" or "OFFLINE"

  • 1≤1 \leq int(events[i][1]) ≤105\leq 10^5

  • The number of id<number> mentions in any "MESSAGE" event is between 11 and 100100

  • 0≤0 \leq <number> ≤\leq numberOfUsers −1- 1

  • It is guaranteed that the user id referenced in the OFFLINE event is online at the time the event occurs.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Mentions Per User

Try to solve the Count Mentions Per User problem.

Statement

You are given an integer numberOfUsers representing the total number of users, indexed from 00 to numberOfUsers −1- 1.

You are also given an array events of length nn, where events[i] = [eventType, timestamp, mentionsString].

All users are initially online. When a user goes offline, they remain offline for 6060 units of time and automatically return online at timestamp +60+ 60.

There are two types of events:

  1. Message Event: eventType is "MESSAGE"

    • The event occurs at timestamp.

    • mentionsString can take one of the following formats:

      • "ALL": Mentions every user, whether they are online or offline.

      • "HERE": Mentions all users who are currently online.

      • A space separated string of user identifiers formatted as id<number> (for example, "id1 id0"): Mentions the specified users. Each occurrence of an identifier adds 11 mention to that user, regardless of their online status.

  2. Offline Event: eventType is "OFFLINE"

    • The user with ID int(mentionsString) goes offline at timestamp and will be back online at timestamp +60+ 60.

Return an array mentions of length numberOfUsers, where mentions[i] represents the total number of mentions user ii received across all events.

Note: Events might not be sorted by timestamp. If multiple events occur at the same timestamp, all "OFFLINE" events must be processed before any "MESSAGE" events.

Constraints:

  • 1≤1 \leq numberOfUsers ≤100\leq 100

  • 1≤1 \leq events.length ≤100\leq 100

  • events[i].length =3= 3

  • events[i][0] will be one of "MESSAGE" or "OFFLINE"

  • 1≤1 \leq int(events[i][1]) ≤105\leq 10^5

  • The number of id<number> mentions in any "MESSAGE" event is between 11 and 100100

  • 0≤0 \leq <number> ≤\leq numberOfUsers −1- 1

  • It is guaranteed that the user id referenced in the OFFLINE event is online at the time the event occurs.