Type an input and write what you think is the output . Each problem is converted to Web Assembly, so any possible input will show the corresponding output. Only correct predictions count.
Locked until you have predicted 3 outputs correctly.
| 1 | vector<vector<string>> solution(const vector<string>& words) { |
| 2 | |
| 3 | map<string, vector<string>> buckets; |
| 4 | |
| 5 | for (const string& w : words) { |
| 6 | |
| 7 | string key = w; |
| 8 | sort(key.begin(), key.end()); |
| 9 | |
| 10 | buckets[key].push_back(w); |
| 11 | } |
| 12 | |
| 13 | vector<vector<string>> ans; |
| 14 | |
| 15 | for (const auto& b : buckets) { |
| 16 | ans.push_back(b.second); |
| 17 | } |
| 18 | |
| 19 | return ans; |
| 20 | } |
Names have been stripped. The signature is the only clue you get for free. Compiled as C++20 with the standard headers and using namespace std; already in scope.