1239
class Solution {
StringBuilder stringbuilder = new StringBuilder();
int res = 0;
public int maxLength(List<String> arr) {
dfs(arr, 0);
return res;
}
public void dfs(List<String> arr, int start){
char[] ch = stringbuilder.toString().toCharArray();
Set<Character> set = new HashSet<>();
for(char iter:ch){
if(set.contains(iter)){
return;
} else {
set.add(iter);
}
}
res = Math.max(res, stringbuilder.length());
for(int i = start; i < arr.size(); i++){
stringbuilder.append(arr.get(i));
dfs(arr, i+1);
stringbuilder.delete(stringbuilder.length() - arr.get(i).length(), stringbuilder.length());
}
}
}