add new solutions

This commit is contained in:
kanna5 2026-01-05 16:48:03 +09:00
parent d798d5e8c9
commit 886b5e0a8e
Signed by: kkyy
GPG key ID: 06332F3965E9B0CF
34 changed files with 1164 additions and 0 deletions

View file

@ -0,0 +1,22 @@
package q49
import "slices"
func groupAnagrams(strs []string) [][]string {
groups := map[string][]string{}
for i := range strs {
byt := []byte(strs[i])
slices.Sort(byt)
sorted := string(byt)
groups[sorted] = append(groups[sorted], strs[i])
}
ret := make([][]string, 0, len(groups))
for _, g := range groups {
ret = append(ret, g)
}
return ret
}
var _ = groupAnagrams