File tree 1 file changed +4
-5
lines changed
Neetcode/Neetcode_150/Group_Anagrams
1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -4,14 +4,14 @@ def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
4
4
5
5
# # Step 1
6
6
# anagrams = defaultdict(list) # Initialize a dictionary to hold lists of anagrams
7
-
7
+
8
8
# # Iterate over each word in the list
9
9
# for word in strs:
10
10
# # Sort the characters of the word to use as the key
11
11
# sorted_word = ''.join(sorted(word))
12
12
# # Group anagrams together using the sorted word as the key
13
13
# anagrams[sorted_word].append(word)
14
-
14
+
15
15
# # Convert the dictionary values (which are lists of anagrams) to a list of lists
16
16
# return list(anagrams.values())
17
17
@@ -35,14 +35,14 @@ def groupAnagrams(self, strs):
35
35
"""
36
36
# # Step 1
37
37
# anagrams = defaultdict(list) # Initialize a dictionary to hold lists of anagrams
38
-
38
+
39
39
# # Iterate over each word in the list
40
40
# for word in strs:
41
41
# # Sort the characters of the word to use as the key
42
42
# sorted_word = ''.join(sorted(word))
43
43
# # Group anagrams together using the sorted word as the key
44
44
# anagrams[sorted_word].append(word)
45
-
45
+
46
46
# # Convert the dictionary values (which are lists of anagrams) to a list of lists
47
47
# return list(anagrams.values())
48
48
@@ -55,4 +55,3 @@ def groupAnagrams(self, strs):
55
55
count [ord (c ) - ord ("a" )] += 1
56
56
ans [tuple (count )].append (s )
57
57
return ans .values ()
58
-
You can’t perform that action at this time.
0 commit comments