-
Notifications
You must be signed in to change notification settings - Fork 481
/
1152.cpp
36 lines (36 loc) · 1.03 KB
/
1152.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class Solution
{
public:
vector<string> mostVisitedPattern(vector<string>& username, vector<int>& timestamp, vector<string>& website)
{
map<vector<string>, set<string>> data;
int n = username.size();
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < n; ++j)
{
if (timestamp[i] < timestamp[j] and
username[i] == username[j])
{
for (int k = 0; k < n; ++k)
{
if (timestamp[j] < timestamp[k] and
username[j] == username[k])
data[{website[i], website[j], website[k]}].insert(username[k]);
}
}
}
}
vector<string> res;
int s = 0;
for (auto& it : data)
{
if (it.second.size() > s)
{
res = it.first;
s = it.second.size();
}
}
return res;
}
};