<p>Given an array of strings <code>strs</code>, group the <span data-keyword="anagram">anagrams</span> together. You can return the answer in <strong>any order</strong>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">strs = [&quot;eat&quot;,&quot;tea&quot;,&quot;tan&quot;,&quot;ate&quot;,&quot;nat&quot;,&quot;bat&quot;]</span></p>

<p><strong>Output:</strong> <span class="example-io">[[&quot;bat&quot;],[&quot;nat&quot;,&quot;tan&quot;],[&quot;ate&quot;,&quot;eat&quot;,&quot;tea&quot;]]</span></p>

<p><strong>Explanation:</strong></p>

<ul>
	<li>There is no string in strs that can be rearranged to form <code>&quot;bat&quot;</code>.</li>
	<li>The strings <code>&quot;nat&quot;</code> and <code>&quot;tan&quot;</code> are anagrams as they can be rearranged to form each other.</li>
	<li>The strings <code>&quot;ate&quot;</code>, <code>&quot;eat&quot;</code>, and <code>&quot;tea&quot;</code> are anagrams as they can be rearranged to form each other.</li>
</ul>
</div>

<p><strong class="example">Example 2:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">strs = [&quot;&quot;]</span></p>

<p><strong>Output:</strong> <span class="example-io">[[&quot;&quot;]]</span></p>
</div>

<p><strong class="example">Example 3:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">strs = [&quot;a&quot;]</span></p>

<p><strong>Output:</strong> <span class="example-io">[[&quot;a&quot;]]</span></p>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= strs.length &lt;= 10<sup>4</sup></code></li>
	<li><code>0 &lt;= strs[i].length &lt;= 100</code></li>
	<li><code>strs[i]</code> consists of lowercase English letters.</li>
</ul>

constexpr array<char, 26> primes = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                                    29, 31, 37, 41, 43, 47, 53, 59, 61,
                                    67, 71, 73, 79, 83, 89, 97, 101};

struct Solution {
    vector<vector<string>> groupAnagrams(const vector<string>& strs) const {
        return {};
    }

    void func(string_view strs) const {
        unordered_map<double, vector<string>> data(strs.length()/100);
        int i = 0;
        double j = 1;
        string tmp;
        for (const char c : strs) {
            switch (c) {
            case '[':
            case '"':
            case ' ':
                continue;
            case ']':
            case ',':
                data.insert({j, vector<string>()}).first->second.push_back(tmp);
                j = 1;
                tmp.clear();
                continue;
            default:
                tmp.push_back(c);
                j *= primes[c - 'a'];
            }
        }

        i = 0;
        cout << '[';
        bool first = false;
        for (auto& it : data) {
            if (first)
                cout << ',';
            else
                first = true;
            cout << '[';
            bool first2 = false;
            for (string& str : it.second) {
                if (first2)
                    cout << ',';
                else
                    first2 = true;
                cout << '"' << str << '"';
            }
            cout << ']';
        }
        cout << ']' << endl;
    }
};

int init = [] {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ofstream out("user.out");
    cout.rdbuf(out.rdbuf());

    Solution s;
    for (string line; getline(cin, line);)
        s.func(line);

    exit(0);
    return 0;
}();
12665