Skip to content

Practice Count Words Obtained After Adding a Letter

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

Medium#2135
LeetCode Problem

Count Words Obtained After Adding a Letter

Problem Statement

For each targetWords entry, check whether some startWords entry can produce it by adding exactly one lowercase letter absent from that starting word, then rearranging the letters arbitrarily. Count qualifying target entries. Each check is independent and starting words are not consumed or changed.

Source: Count Words Obtained After Adding a Letter on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
startWords = ["ant","act","tack"], targetWords = ["tack","act","acti"]
Output
2

# Example 2

Input
startWords = ["ab","a"], targetWords = ["abc","abcd"]
Output
1

Constraints

1 <= startWords.length, targetWords.length <= 5 * 10^4
1 <= startWords[i].length, targetWords[j].length <= 26
Each string of startWords and targetWords consists of lowercase English letters only.
No letter occurs more than once in any string of startWords or targetWords.

Related LeetCode Problems

Practice more problems similar to Count Words Obtained After Adding a Letter.

Review your practice with PhantomCodeAI

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