|
3 | 3 | importjava.util.HashMap;
|
4 | 4 | importjava.util.Map;
|
5 | 5 |
|
6 |
| -/** |
7 |
| - * 1160. Find Words That Can Be Formed by Characters |
8 |
| - * |
9 |
| - * You are given an array of strings words and a string chars. |
10 |
| - * A string is good if it can be formed by characters from chars (each character can only be used once). |
11 |
| - * Return the sum of lengths of all good strings in words. |
12 |
| - * |
13 |
| - * Example 1: |
14 |
| - * |
15 |
| - * Input: words = ["cat","bt","hat","tree"], chars = "atach" |
16 |
| - * Output: 6 |
17 |
| - * Explanation: |
18 |
| - * The strings that can be formed are "cat" and "hat" so the answer is 3 + 3 = 6. |
19 |
| - * |
20 |
| - * Example 2: |
21 |
| - * |
22 |
| - * Input: words = ["hello","world","leetcode"], chars = "welldonehoneyr" |
23 |
| - * Output: 10 |
24 |
| - * Explanation: |
25 |
| - * The strings that can be formed are "hello" and "world" so the answer is 5 + 5 = 10. |
26 |
| - * |
27 |
| - * Note: |
28 |
| - * |
29 |
| - * 1 <= words.length <= 1000 |
30 |
| - * 1 <= words[i].length, chars.length <= 100 |
31 |
| - * All strings contain lowercase English letters only. |
32 |
| - * */ |
33 | 6 | publicclass_1160 {
|
34 | 7 | publicstaticclassSolution1 {
|
35 | 8 | publicintcountCharacters(String[]words,Stringchars) {
|
|