Fundamentals/Concatenated String Length with unique Characters
← PrevNext →
Given an array A consisting of N strings, calculate the length of the longest string S such that:
S is a concatenation of some of the Strings from A.
every letter in S is different.
N is [1..8]
A consists of lowercase English letters
Sum of length of strings in A does not exceed 100.
Example 1:
Input: ["co","dil","ity"]
Output: 5
Explanation:
String S could be codil, dilco, coity, ityco
Example 2
Input["abc","kkk","def","csv"]
Output6
Explanation
Strings S could be abcdef, defabc, defcsv, csvdef
Example 3
Input["abc","ade","akl"]
Output0
Explanation
impossible to concatenate as letters won't be unique.