Tap here to switch tabs
Problem
Submissions

Problem: Count Words Obtained After Adding a Letter

med
30 min
Try to solve the Count Words Obtained After Adding a Letter problem.

Statement

You are given two string arrays, startWords and targetWords. For each string in targetWords, you want to determine whether it can be formed by taking a string from startWords, appending exactly one lowercase English letter that was not originally present in that string, and rearranging its characters into any permutation.

Return the total number of strings in targetWords that can be obtained from at least one string in startWords.

Note: Each string in startWords can be used multiple times to obtain different strings in targetWords.

Constraints:

  • 1≤1 \leq startWords.length, targetWords.length ≤5imes104\leq 5 imes 10^4

  • 1≤1 \leq startWords[i].length, targetWords[j].length ≤26\leq 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.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Words Obtained After Adding a Letter

med
30 min
Try to solve the Count Words Obtained After Adding a Letter problem.

Statement

You are given two string arrays, startWords and targetWords. For each string in targetWords, you want to determine whether it can be formed by taking a string from startWords, appending exactly one lowercase English letter that was not originally present in that string, and rearranging its characters into any permutation.

Return the total number of strings in targetWords that can be obtained from at least one string in startWords.

Note: Each string in startWords can be used multiple times to obtain different strings in targetWords.

Constraints:

  • 1≤1 \leq startWords.length, targetWords.length ≤5imes104\leq 5 imes 10^4

  • 1≤1 \leq startWords[i].length, targetWords[j].length ≤26\leq 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.