https://leetcode.com/problems/group-anagrams/
Since this one requires us to group anagrams together, we need come up with a strategy to generate a ‘key’ so that we can use that to group different strings together using a ‘map’ data structure.
Just like we did in valid anagrams we could sort strings -> sorting anagrams produces a unique string -> this string could be used as key in our map. Resulting solution takes O(N k log k) time and O(Nk) space, where k is length of longest string in the input.
Another possible solution which improves the time complexity to O(N k) works by using the fact that input is constraint to lower case english letters – with that constraint, we could convert each character to its ascii value and then construct an array to be used as key -> since creating a key only takes O(26) time – we could consider that as contact time.