[
hash table
string
anagram
]
BinarySearch 0320 Largest Anagram Group
Problem statement
https://binarysearch.com/problems/Largest-Anagram-Group/
Solution
Variation of Leetcode 0049. Group Anagrams.
Complexity
Time complexity will be O(nk * log k)
, space complexity is O(nk)
.
Code
class Solution:
def solve(self, words):
t = defaultdict(list)
for s in words:
t["".join(sorted(s))].append(s)
return max(len(x) for x in t.values())