Find Words That Can Be Formed by Characters Problem

Find Words That Can Be Formed by Characters Problem — ExecCode Easy DSA Practice

Solve the Find Words That Can Be Formed by Characters problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given an array of strings words and a string chars. Your task is to compute the required answer and return the sum of lengths of all good strings in words. A string is good if it can be formed by characters from chars (each character can only be used once for each word in words).

Examples

Input {"words": ["cat", "bt", "hat", "tree"], "chars": "atach"}; Output 6. Input {"words": ["hello", "world", "leetcode"], "chars": "welldonehoneyr"}; Output 10

Constraints

1 <= words.length <= 1000 1 <= words[i].length, chars.length <= 100 words[i] and chars consist of lowercase English letters.

Practice Find Words That Can Be Formed by Characters free on ExecCode. Browse DSA problems, topic map, and placement guides.