-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDay61.cpp
41 lines (40 loc) · 1.37 KB
/
Day61.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
37
38
39
40
41
vector<vector<string>> mergeDetails(vector<vector<string>>& details) {
// code here
vector<vector<string>>vv;
for(int i=0;i<details.size();i++)
{
if(details[i][0]!="-")
{
set<string>s;
vector<string>v;
for(int j=1;j<details[i].size();j++)
{
s.insert(details[i][j]);
}
for(int j=i+1;j<details.size();j++)
{
if(details[j][0]!="-")
{
for(int k=1;k<details[j].size();k++)
{
auto pos=s.find(details[j][k]);
if(pos!=s.end())
{
details[j][0]="-";
for(int k=1;k<details[j].size();k++)
{
s.insert(details[j][k]);
}
}
}
}
}
v.push_back(details[i][0]);
for(auto i=s.begin();i!=s.end();i++) v.push_back(*i);
vv.push_back(v);
}
}
sort(vv.rbegin(),vv.rend()); /* i have reverse that because only 56 test cases passed before this and i did the reverse the vv(vector) then the all test cases passed now…*/
return vv;
}
};