Leetcode Note: Go - Redistribute Characters to Make All Strings Equal
Redistribute Characters to Make All Strings Equal - LeetCode
https://leetcode.com/problems/redistribute-characters-to-make-all-strings-equal/
- Go 言語で取り組んだメモ
回答
Funny solution with Go - Redistribute Characters to Make All Strings Equal - LeetCode
https://leetcode.com/problems/redistribute-characters-to-make-all-strings-equal/solutions/2466222/funny-solution-with-go/?orderBy=most_votes&languageTags=golang
func makeEqual(words []string) bool {
alphabet := make([]int, 26)
for _, word := range words {
for i := 0; i < len(word); i++ {
alphabet[int(word[i] - 'a')]++
}
}
for i := 0; i < 26; i++ {
if alphabet[i] % len(words) != 0 {
return false
}
}
return true
}