Most Unique Letters
MetaOnsiteHard
You are given a list of lowercase words. Pick a subset of the words so that no letter appears more than once across all picked words, counting repeats inside a single word too. A subset's value is the number of distinct letters it covers. Picking nothing is allowed and covers 0 letters.
Part 1: Small lists
Return the largest number of distinct letters a valid subset of words can cover. A word that repeats a letter can never be picked. Picking two copies of the same word repeats all of its letters, so duplicates never help.
- Example 1
- words
["un","iq","ue"]- Output
4
Why:
unandiqshare no letter and coveru,n,i,q— 4 letters.uesharesuwithun, so its best pairing is withiq, which also covers 4.
Constraints
1 <= len(words) <= 161 <= len(words[i]) <= 26'a' <= words[i][j] <= 'z'