Skip to content

Commit b9d7362

Browse files
authored
Create finding-the-users-active-minutes.cpp
1 parent f458560 commit b9d7362

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Time: O(n)
2+
// Space: O(n)
3+
4+
class Solution {
5+
public:
6+
vector<int> findingUsersActiveMinutes(vector<vector<int>>& logs, int k) {
7+
unordered_map<int, unordered_set<int>> lookup;
8+
for (const auto& log : logs) {
9+
lookup[log[0]].emplace(log[1]);
10+
}
11+
vector<int> result(k);
12+
for (const auto& [_, ts] : lookup) {
13+
++result[size(ts) - 1];
14+
}
15+
return result;
16+
}
17+
};

0 commit comments

Comments
 (0)