The auto-disqualification of words with internal duplicate letters (like 'apple') is easy to miss if you jump straight to the subset logic.
First, validate and preprocess each word by checking for duplicate letters and converting it to a bitmask. Then, use backtracking to explore all valid subsets, pruning branches when the current union of characters cannot exceed the best found so far. Return the maximum bit count among valid subsets.
Pro tip: Mention that you can deduplicate words by their bitmask and sort them by popcount descending to improve pruning. Also, note that the maximum possible answer is 26, so you can early-exit if you reach that.
Iterate through the list, discard any word with repeated letters, and represent each valid word as a 26-bit integer mask.
Remove duplicate masks and sort the remaining masks in descending order of their popcount to prioritize words that cover more unique characters.
Recursively explore subsets, maintaining the current union mask. At each step, if the union already has no overlap with the next word's mask, include it; otherwise skip. Prune if the current union's popcount plus the sum of remaining words' popcounts cannot exceed the best found.
Keep a global maximum of the popcount of the union mask. After exploring all valid subsets, return this maximum.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.