Skip to content

Practice Find Words That Can Be Formed by Characters

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#1160
LeetCode Problem

Find Words That Can Be Formed by Characters

Problem Statement

You are given an array of strings words and a string chars. 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). Return the sum of lengths of all good strings in words.

Source: Find Words That Can Be Formed by Characters on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
words = ["cat","bt","hat","tree"], chars = "atach"
Output
6

# Example 2

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.

Related LeetCode Problems

Practice more problems similar to Find Words That Can Be Formed by Characters.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.