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

1239. Maximum Length of a Concatenated String with Unique Characters

题目地址

https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters/

题目描述

Given an array of strings arr. String s is a concatenation of a sub-sequence of arr which have unique characters.

Return the maximum possible length of s.

Example 1:
Input: arr = ["un","iq","ue"]
Output: 4
Explanation: All possible concatenations are "","un","iq","ue","uniq" and "ique".
Maximum length is 4.

Example 2:
Input: arr = ["cha","r","act","ers"]
Output: 6
Explanation: Possible solutions are "chaers" and "acters".
Example 3:

Input: arr = ["abcdefghijklmnopqrstuvwxyz"]
Output: 26

代码

Approach 1: Bit Operation

Approach #2 DFS

Last updated

Was this helpful?