Maximum Length of a Unique Concatenation
You are given an array of strings arr.
You need to choose a subsequence of strings from arr and concatenate them in the same order. The final concatenated string must contain only unique characters, meaning no character should appear more than once in the entire string.
Return the maximum possible length of such a valid concatenated string.
A subsequence is formed by deleting some or no elements from the array without changing the order of the remaining elements.
Example 1:
Input: arr = ["ab", "cd", "aef"]
Output: 5
Explanation:
The maximum possible length is 5.
Example 2:
Input: arr = ["aa", "bc", "def"]
Output: 5
Explanation:
The answer is 5.
Now Your Turn!
Pick the correct output for the given inputInput: arr = ["ab", "bc", "de"]
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= arr.length <= 16
- 1 <= arr[i].length <= 26
- arr[i] contains only lowercase English letters