From 50b4275d6e4084638bd24758a6ca1d3c49321173 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Fri, 1 Dec 2023 22:30:56 -0500 Subject: 1160 --- 1160/main.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 1160/main.go 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 +} -- cgit v1.2.3