You are given an array of strings arr. Your task is to find the maximum possible length of a string formed by concatenating a subsequence of these strings, where the resulting string contains only unique characters.
A subsequence is derived from the original array by selecting some (or none) of the strings while maintaining their relative order. For example, from ["a", "b", "c"], valid subsequences include ["a", "c"], ["b"], or [].
Key constraints:
- The concatenated result must have all unique characters
- You want to maximize the length of this result
- Individual strings in the input may already contain duplicate characters (these should be ignored)
Example: Given ["un", "iq", "ue"], you can form "unique" by concatenating all three strings, resulting in length 6.
Input & Output
Visualization
Time & Space Complexity
2^n subsequences to check, each taking O(m) time to validate where m is average string length
Space for concatenated strings and character frequency checking
Constraints
- 1 โค arr.length โค 16
- 1 โค arr[i].length โค 26
- arr[i] contains only lowercase English letters
- The maximum possible length will not exceed 26 (since there are only 26 unique lowercase letters)