Search⌘ K
AI Features

Solution: Word Subsets

C# solution for the Word Subsets problem using the Knowing What to Track pattern.

Statement

You are given two string arrays words1 and words2. A string w in words1 is called a universal word if, for every string b in words2, b is a subset of w in terms of character counts. In other words, for each lowercase letter, w must contain that letter at least as many times as it appears in b.

Return all strings in words1 that are universal with respect to words2.

Constraints:

  • 11 \leq words1.length, words2.length 104\leq 10^4

  • ...