Maximize Unique Characters from Words
MetaSoftware Engineer · OnsiteLast updated
This question evaluates a candidate's ability to reason about combinatorial constraints and set disjointness while maximizing unique coverage, testing competencies in algorithm design, combinatorics, and constraint-based optimization.
You are given a list of lowercase English words. Select a subset of the words such that no character appears more than once across all selected words. In other words, every selected word must have no duplicate letters internally, and any two selected words must have disjoint character sets.
Return the maximum possible number of unique characters covered by a valid subset.
Example:
- Input:
["un", "iq", "ue"] - Output:
4 - Explanation: Select
"un"and"iq"to cover four unique characters.
Clarify edge cases:
- A word containing duplicate letters, such as
"aa", cannot be selected. - The empty subset is allowed and covers
0characters. - Assume the alphabet is lowercase English letters unless otherwise specified.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.