<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>

class Solution:
    def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
        found_anagrams={}
        anagrams_groups =[]
        for i, str in enumerate(strs):
            str_hashmap= {}
            str_group=[]
            str_group.append(str)
            if str not in found_anagrams:
                # for c in str:
                #     str_hashmap[c] = 1 + str_hashmap.get(c, 0)
                sorted_str= sorted(str)
                
                for j in range(i+1, len(strs)):
                    if len(str) == len(strs[j]):
                        # str_j_hashmap ={}
                        # for c in strs[j]:
                        #     str_j_hashmap[c] = 1 + str_j_hashmap.get(c, 0)

                        sorted_str_j = sorted(strs[j])
                        
                        # anagram=True
                        # for c in str:
                            # if str_hashmap[c] != str_j_hashmap.get(c, 0):
                            #     anagram = False
                        if sorted_str==sorted_str_j:
                        # if anagram:
                            str_group.append(strs[j])
                            found_anagrams[strs[j]] = "Grouped"

                anagrams_groups.append(str_group)


        return anagrams_groups

        
18600