My first instinct was greedy and it was wrong.
Model each word as a bitmask of its letters, then use backtracking with pruning to explore subsets, ensuring no letter overlap. Alternatively, use dynamic programming over masks to maximize distinct letters, but backtracking with memoization is often simpler and efficient for typical constraints.
Pro tip: Precompute letter masks and immediately discard words with duplicate letters, as they can never be part of a valid subset. Also, sort words by number of distinct letters descending to find good solutions early and prune more aggressively.
Ask about input size, character set (lowercase only?), and whether words can have repeated letters. Confirm that the goal is to maximize distinct letters, not number of words.
Convert each word to a 26-bit integer where each bit indicates presence of a letter. Filter out words with internal duplicate letters (mask popcount != word length).
Use DFS to try including/excluding each word, maintaining a combined mask. Prune if adding a word causes overlap or if the maximum possible additional letters cannot beat the current best.
If constraints are large, use DP over masks: dp[mask] = max letters achievable using words that fit in mask. Or memoize on (index, current_mask) to avoid recomputation.
Discuss time/space complexity (e.g., O(2^N) worst-case for backtracking, or O(2^26 * N) for DP). Walk through a small example to verify correctness.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.