Tap here to switch tabs
Problem
Submissions

Problem: Word Subsets

med
30 min
Try to solve the Word Subsets problem.

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:

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

  • 1≤1 \leq words1[i].length, words2[i].length ≤10\leq 10

  • words1[i] and words2[i] consist only of lowercase English letters

  • All strings in words1 are unique

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Word Subsets

med
30 min
Try to solve the Word Subsets problem.

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:

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

  • 1≤1 \leq words1[i].length, words2[i].length ≤10\leq 10

  • words1[i] and words2[i] consist only of lowercase English letters

  • All strings in words1 are unique