diff options
Diffstat (limited to '')
-rw-r--r-- | 1160/main.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/1160/main.go b/1160/main.go new file mode 100644 index 0000000..84e9c21 --- /dev/null +++ b/1160/main.go @@ -0,0 +1,26 @@ +package main + +func countCharacters(words []string, chars string) int { + var cnt int + charMap := make(map[rune]int) + for _, v := range chars { + charMap[v]++ + } + for _, v := range words { + tmpMap := make(map[rune]int) + for _, vv := range v { + tmpMap[vv]++ + } + var flag bool + for k, v := range tmpMap { + if charMap[k] < v { + flag = true + break + } + } + if !flag { + cnt += len(v) + } + } + return cnt +} |