diff options
author | terminaldweller <devi@terminaldweller.com> | 2023-12-02 03:30:56 +0000 |
---|---|---|
committer | terminaldweller <devi@terminaldweller.com> | 2023-12-02 03:30:56 +0000 |
commit | 50b4275d6e4084638bd24758a6ca1d3c49321173 (patch) | |
tree | 3f9f070cd2ccb809d757dbde33bba2b7e641c99a /1160/main.go | |
parent | 502 (diff) | |
download | leetcode-50b4275d6e4084638bd24758a6ca1d3c49321173.tar.gz leetcode-50b4275d6e4084638bd24758a6ca1d3c49321173.zip |
1160
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 +} |