Skip to content

Commit

Permalink
add sol
Browse files Browse the repository at this point in the history
  • Loading branch information
ductnn committed Dec 30, 2023
1 parent 44e0bde commit 6e8cac4
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// https://leetcode.com/problems/redistribute-characters-to-make-all-strings-equal/

package main

import (
"fmt"
)

func makeEqual(words []string) bool {
n := len(words)
count := make([]int, 26)

for _, word := range words {
for _, w := range word {
count[w-'a']++
}
}

for i := 0; i < 26; i++ {
if count[i]%n != 0 {
return false
}
}

return true
}

func main() {
words := []string{"abc", "aabc", "bc"}

fmt.Println(makeEqual(words))
}

0 comments on commit 6e8cac4

Please sign in to comment.