We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d4146e9 commit 533e8b9Copy full SHA for 533e8b9
ArraysAndHashing/Medium/49_Group_Anagrams.py
@@ -41,6 +41,12 @@
41
# Total Complexity: O(N log N + N K log K)
42
# Space Complexity: O(N K)
43
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
+
50
class Solution:
51
def groupAnagrams(self, strs):
52
new_val = sorted(strs)
@@ -59,6 +65,11 @@ def groupAnagrams(self, strs):
59
65
# Time Complexity: O(m*n)
60
66
# Space Complexity: O(m)
61
67
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
71
72
62
73
from collections import defaultdict
63
74
64
75
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments