package
0.0.0-20240615115840-a222ecda5fb5
Repository: https://github.com/koykov/algoexpert.io.git
Documentation: pkg.go.dev
# README
Group Anagrams
Category: Strings
Difficulty: Medium
Description
Write a function that takes in an array of strings and groups anagrams together.
Anagrams are strings made up of exactly the same letters, where order doesn't
matter. For example, "cinema"
and "iceman"
are
anagrams; similarly, "foo"
and "ofo"
are anagrams.
Your function should return a list of anagram groups in no particular order.
Sample Input
words = ["yo", "act", "flop", "tac", "foo", "cat", "oy", "olfp"]
Sample Output
[["yo", "oy"], ["flop", "olfp"], ["act", "tac", "cat"], ["foo"]]
Optimal Space & Time Complexity
O(w * n * log(n)) time | O(wn) space - where w is the number of words and n is the length of the longest word