1239. Maximum Length of a Concatenated String with Unique Characters Medium

@problem@discussion
#Array#String#Backtracking#Bit Manipulation



1/**
2 * [1239] Maximum Length of a Concatenated String with Unique Characters
3 *
4 * You are given an array of strings arr. A string s is formed by the concatenation of a subsequence of arr that has unique characters.
5 * Return the maximum possible length of s.
6 * A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.
7 *  
8 * Example 1:
9 * 
10 * Input: arr = ["un","iq","ue"]
11 * Output: 4
12 * Explanation: All the valid concatenations are:
13 * - ""
14 * - "un"
15 * - "iq"
16 * - "ue"
17 * - "uniq" ("un" + "iq")
18 * - "ique" ("iq" + "ue")
19 * Maximum length is 4.
20 * 
21 * Example 2:
22 * 
23 * Input: arr = ["cha","r","act","ers"]
24 * Output: 6
25 * Explanation: Possible longest valid concatenations are "chaers" ("cha" + "ers") and "acters" ("act" + "ers").
26 * 
27 * Example 3:
28 * 
29 * Input: arr = ["abcdefghijklmnopqrstuvwxyz"]
30 * Output: 26
31 * Explanation: The only string in arr has all 26 characters.
32 * 
33 *  
34 * Constraints:
35 * 
36 * 	1 <= arr.length <= 16
37 * 	1 <= arr[i].length <= 26
38 * 	arr[i] contains only lowercase English letters.
39 * 
40 */
41pub struct Solution {}
42
43// problem: https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters/
44// discuss: https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters/discuss/?currentPage=1&orderBy=most_votes&query=
45
46// submission codes start here
47
48impl Solution {
49    pub fn max_length(arr: Vec<String>) -> i32 {
50        0
51    }
52}
53
54// submission codes end
55
56#[cfg(test)]
57mod tests {
58    use super::*;
59
60    #[test]
61    fn test_1239() {
62    }
63}
64


Back
© 2025 bowen.ge All Rights Reserved.