Maximum Length of Concatenated String with Unique Characters
Given an array of strings arr, form the longest possible concatenation of a subsequence of arr such that the concatenated string contains no repeated characters. Return that maximum length.
Open official problem prompt ↗Find the largest number of distinct letters obtainable by gluing together some chosen subset of the given strings.
Think of each string as a Scrabble tile bearing a fixed set of letters. You may lay down tiles only if no letter repeats across everything on the board. You try combinations to maximize how many distinct letters end up on the board.
- Input
- arr = ["un", "iq", "ue"]
- Output
- 4
- Why
- Concatenating "un" + "iq" gives "uniq" (4 unique letters); "un" + "ue" repeats 'u' and is invalid, so 4 is the best.
1 <= arr.length <= 161 <= arr[i].length <= 26arr[i] contains only lowercase English letters