Loading Similar Posts
Question 1 solution
vector<vector<string>> sol(vector<string> w,vector<string> q)
{
map<string,vector<string>> mp;
for(auto i:w)
{
string j=i;
sort(j.begin(),j.end());
mp[j].push_back(i);
}
vector<vector<string>> ans;
for(auto i:q)
{
string j=i;
sort(j.begin(),j.end());
sort(mp[j].begin(),mp[j].end());
ans.pb(mp[j]);
}
return ans;
}