Easy · Strings

Find all subset words

Given a string text and a list of words, return (in any order) every word that can be spelled from text's letters, using each letter at most as many times as it occurs in text; each word is checked on its own against all of text.

Examples

Example 1

text="codebase" · 5 words

Output: [code, base, cab, ace, bad]

Example 2

text="aabbc" · 3 words

Output: [abc, aab]

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Strings problems