Skip to content

Commit e4923c6

Browse files
committed
Update 49-group_anagrams.py
1 parent 8620d5d commit e4923c6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

49-group_anagrams.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
caste that to a string. For example, "abe" becomes [a: 1, b: 1, e: 1], aka [1, 1, 0, 0, 1, 0, 0, ...],
88
where index 1 is a, index 2 is b, index 3 is c, etc. At the end, the values in the dictionary are our groups.
99
10-
Runtime: O(n\*m) time, O(n+m) space
10+
Runtime: O(n*m) time, O(n+m) space
1111
The actual runtimes aren't phenomenal, but it's good in terms of Big Oh. Essentially, we run through
1212
every word in strs (which takes O(n) time) and we generate an occurrence list for every char (max of
13-
O(m) time. All together, that is O(n\*m) time.
13+
O(m) time. All together, that is O(n*m) time.
1414
Runtime: 136 ms, faster than 41.31% of Python online submissions for Group Anagrams.
1515
Memory Usage: 16.7 MB, less than 14.58% of Python online submissions for Group Anagrams.
1616
"""

0 commit comments

Comments
 (0)