leetcode2sumc 1160. find words that can be formed by characters
leetcode 2和c 1160.-find-words-that-can-be-formed-by-characters-c-map。leetcode给你一个字符串数组words
和一个字符串chars
。如果字符串可以由字符中的字符组成(每个字符只能使用一次),则该字符串是好的。返回单词中所有好的字符串的长度总和。
示例1:
输入:words = ["cat","bt","hat","tree"]
,chars = "atach"
输出:6
解释:可以组成的字符串是“cat”和“hat”,所以答案是3 + 3 = 6。
示例2:
输入:words = ["hello","world","leetcode"]
,chars = "welldoneyr"
输出:10
解释:可以组成的字符串是"hello"和"world",所以答案是5 + 5 = 10。