Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 533e8b9

Browse files
49. Group Anagrams
1 parent d4146e9 commit 533e8b9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎ArraysAndHashing/Medium/49_Group_Anagrams.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
# Total Complexity: O(N log N + N K log K)
4242
# Space Complexity: O(N K)
4343

44+
'''
45+
In the below approach, we sorted the strings in order to identify if they are anagrams.
46+
We then used a dictionary to store the sorted strings as key and the original strings as values.
47+
Finally we returned the values of the dictionary.
48+
'''
49+
4450
class Solution:
4551
def groupAnagrams(self, strs):
4652
new_val = sorted(strs)
@@ -59,6 +65,11 @@ def groupAnagrams(self, strs):
5965
# Time Complexity: O(m*n)
6066
# Space Complexity: O(m)
6167

68+
'''
69+
In the below approach, we used a dictionary to store the count of each character in the string as key and the original string as value.
70+
Finally we returned the values of the dictionary.
71+
'''
72+
6273
from collections import defaultdict
6374

6475
class Solution:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /