Tap here to switch tabs
Problem
Submissions

Problem: Find Words That Can Be Formed by Characters

Find Words That Can Be Formed by Characters checks an array of strings against available characters and returns the total length of words formed without reusing any character.

Statement

You are given an array of strings words and a string chars.

A string in words is considered good if it can be formed using only the characters available in chars, where each character in chars may be used at most once per word.

Return the sum of the lengths of all good strings in words.

Constraints:

  • 1≤1 \leq words.length ≤1000\leq 1000

  • 1≤1 \leq words[i].length, chars.length ≤100\leq 100

  • words[i] and chars consist of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Words That Can Be Formed by Characters

Find Words That Can Be Formed by Characters checks an array of strings against available characters and returns the total length of words formed without reusing any character.

Statement

You are given an array of strings words and a string chars.

A string in words is considered good if it can be formed using only the characters available in chars, where each character in chars may be used at most once per word.

Return the sum of the lengths of all good strings in words.

Constraints:

  • 1≤1 \leq words.length ≤1000\leq 1000

  • 1≤1 \leq words[i].length, chars.length ≤100\leq 100

  • words[i] and chars consist of lowercase English letters.