Meta questions

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.

  1. Example 1
    words
    ["un","iq","ue"]
    Output
    4

    Why: un and iq share no letter and cover u, n, i, q — 4 letters. ue shares u with un, so its best pairing is with iq, which also covers 4.

Constraints

  • 1 <= len(words) <= 16
  • 1 <= len(words[i]) <= 26
  • 'a' <= words[i][j] <= 'z'
Most Unique Letters: Meta interview question | LoopCoach