Easy · Strings

Find All Subset Words

Given an ASCII-letter string text and a list of ASCII-letter 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

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

More Strings problems