Tap here to switch tabs
Problem
Submissions

Problem: Finding the Users Active Minutes

med
30 min
Try to solve the Finding the Users Active Minutes problem.

Statement

You are given the activity logs of users on a platform and an integer k. The logs are represented by a 2extD2 ext{D} integer array logs, where each logs[i] =[extIDi,exttimei]= [ ext{ID}_i, ext{time}_i] indicates that the user with ID $ ext{ID}_i$ performed an action at minute $ ext{time}_i$.

Multiple users can perform actions simultaneously, and a single user can perform multiple actions in the same minute.

The User Active Minutes (UAM) for a user is defined as the number of unique minutes during which the user performed at least one action. Even if a user performs multiple actions within the same minute, that minute is only counted once toward their UAM.

Return a 11 indexed integer array answer of size k such that, for each jj (1≤j≤1 \leq j \leq k), answer[j - 1] is the number of users whose UAM is equal to jj.

Constraints:

  • 1≤1 \leq logs.length ≤104\leq 10^4

  • 0≤extIDi≤1090 \leq ext{ID}_i \leq 10^9

  • 1≤exttimei≤1051 \leq ext{time}_i \leq 10^5

  • k is in the range [extThemaximumUAMforauser,105][ ext{The maximum UAM for a user}, 10^5]

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Finding the Users Active Minutes

med
30 min
Try to solve the Finding the Users Active Minutes problem.

Statement

You are given the activity logs of users on a platform and an integer k. The logs are represented by a 2extD2 ext{D} integer array logs, where each logs[i] =[extIDi,exttimei]= [ ext{ID}_i, ext{time}_i] indicates that the user with ID $ ext{ID}_i$ performed an action at minute $ ext{time}_i$.

Multiple users can perform actions simultaneously, and a single user can perform multiple actions in the same minute.

The User Active Minutes (UAM) for a user is defined as the number of unique minutes during which the user performed at least one action. Even if a user performs multiple actions within the same minute, that minute is only counted once toward their UAM.

Return a 11 indexed integer array answer of size k such that, for each jj (1≤j≤1 \leq j \leq k), answer[j - 1] is the number of users whose UAM is equal to jj.

Constraints:

  • 1≤1 \leq logs.length ≤104\leq 10^4

  • 0≤extIDi≤1090 \leq ext{ID}_i \leq 10^9

  • 1≤exttimei≤1051 \leq ext{time}_i \leq 10^5

  • k is in the range [extThemaximumUAMforauser,105][ ext{The maximum UAM for a user}, 10^5]