Number of Valid Words for Each Puzzle

Given arrays words and puzzles, return one count for each puzzle. A word is valid when it contains the puzzle's first letter and every letter in the word occurs in that puzzle. Repeated words are counted repeatedly.

  • Input: words = ["aaaa", "asas", "able", "ability", "actt", "actor", "access"], puzzles = ["aboveyz", "abrodyz"]
  • Output: [1, 1]
Examples
Input: []
Output: 0
Hints

Number of Valid Words for Each Puzzle

Given arrays `words` and `puzzles`, return one count for each puzzle. A word is valid when it contains the puzzle's first letter and every letter in the word occurs in that puzzle. Repeated words are counted repeatedly.