Medium · Strings

Count Words Obtained After Adding a Letter

Given two arrays of lowercase words, startWords and targetWords, where no word repeats a letter, return how many target words can be formed by appending to some start word one letter it does not already contain and then rearranging the letters in any order.

Examples

Example 1

{
  "startWords": ["ant", "act", "tack"],
  "targetWords": ["tack", "act", "acti"]
}

Output: 2 words

Example 2

{
  "startWords": ["ab", "a"],
  "targetWords": ["abc", "abcd"]
}

Output: 1 word

Rebuild it in the studio

Core interview problems are free with a full runner and lessons; Pro opens the complete library.

More Strings problems