Hotel Reviews Time : Space : 12345678910111213141516171819202122232425262728void modify(string& s) { for(int i = 0; i < s.length(); i++) if(s[i] == '_') s[i] = ' ';}vector<int> Solution::solve(string A, vector<string> &B) { modify(A); stringstream ss; string now; ss<<A; unordered_set<string> good; while(ss>>now) good.insert(now); vector<pair<int, int>> S; for(int i = 0; i < B.size(); i++) { modify(B[i]); ss.clear(); ss<<B[i]; int score = 0; while(ss>>now) if(good.count(now)) score += 1; S.push_back({score,i}); } sort(begin(S), end(S), [](auto a, auto b) { if(a.first == b.first) return a.second < b.second; return a.first > b.first; }); vector<int> res; for(auto [_, idx] : S) res.push_back(idx); return res;}