MCPcopy Create free account
hub / github.com/austingebauer/go-leetcode / encodeString

Function encodeString

group_anagrams_49/solution.go:27–39  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

25}
26
27func encodeString(s string) string {
28 chars := make([]int, 26)
29 for i := 0; i < len(s); i++ {
30 chars[s[i]-'a']++
31 }
32
33 encoded := &bytes.Buffer{}
34 for i := 0; i < len(chars); i++ {
35 encoded.WriteString(fmt.Sprintf("%d_%d", i, chars[i]))
36 }
37
38 return encoded.String()
39}
40
41// Second solution based on sorting the strings
42func groupAnagrams1(strs []string) [][]string {

Callers 1

groupAnagramsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected