-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path0609.cpp
More file actions
30 lines (27 loc) · 788 Bytes
/
Copy path0609.cpp
File metadata and controls
30 lines (27 loc) · 788 Bytes
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
#pragma GCC optimize("fast")
static auto _ = []() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
return 0;
}();
class Solution {
public:
vector<vector<string>> findDuplicate(const vector<string> &paths) {
unordered_map<string, vector<string>> um;
vector<vector<string>> res;
string path, file;
for (const string &entry : paths) {
stringstream ss(entry);
ss >> path;
path += '/';
while (ss >> file) {
int idx = file.find('(');
um[file.substr(idx)].push_back(path + file.substr(0, idx));
}
}
for (const auto &[_, v] : um)
if (v.size() > 1) res.push_back(v);
return res;
}
};