Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- unordered_map<string, vector<string>> files;
- vector<vector<string>> ans;
- vector<vector<string>> findDuplicate(vector<string>& paths) {
- for(auto content: paths){
- stringstream ss(content);
- string root, file;
- getline(ss, root, ' ');
- while(getline(ss, file, ' ')){
- string path = root+"/"+file.substr(0, file.find('('));
- string content = file.substr(file.find('(')+1, file.find(')')-file.find('(')-1);
- files[content].push_back(path);
- }
- }
- for(auto file: files)
- if(file.second.size() > 1)
- ans.push_back(file.second);
- return ans;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement