[Python/C++/Java] Set Solution
Explanation\n\n0. Initial the result res to include the case of empty string "".\nres include all possible combinations we find during we iterate the input.\n\n
## **Explanation**\n\n0. Initial the result `res` to include the case of empty string `""`.\n`res` include all possible combinations we find during we iterate the input.\n\n1. Itearte the the input strings,\nbut skip the word that have duplicate characters.\nThe examples is kind of misleading,\nbut the input string can have duplicate characters,\nno need to considerate these strings.\n\n3. For each string,\nwe check if it\'s conflit with the combination that we found.\nIf they have intersection of characters, we skip it.\nIf not, we append this new combination to result.\n\n4. return the maximum length from all combinations.\n<br>\n\n**Python:**\n```python\n    def maxLength(self, A):\n        dp = [set()]\n        for a in A:\n            if len(set(a)) < len(a): continue\n            a = set(a)\n            for c in dp[:]:\n                if a & c: continue\n                dp.append(a | c)\n        return max(len(a) for a in dp)\n```\n**C++**\nbased on @savvadia\n```C++\n    int maxLength(vector<string>& A) {\n        vector<bitset<26>> dp = {bitset<26>()};\n        int res = 0;\n        for (auto& s : A) {\n            bitset<26> a;\n            for (char c : s)\n                a.set(c - \'a\');\n            int n = a.count();\n            if (n < s.size()) continue;\n\n            for (int i = dp.size() - 1; i >= 0; --i) {\n                bitset c = dp[i];\n                if ((c & a).any()) continue;\n                dp.push_back(c | a);\n                res = max(res, (int)c.count() + n);\n            }\n        }\n        return res;\n    }\n```\n**Java**\n```java\n    public int maxLength(List<String> A) {\n        List<Integer> dp = new ArrayList<>();\n        dp.add(0);\n        int res = 0;\n        for (String s : A) {\n            int a = 0, dup = 0;\n            for (char c : s.toCharArray()) {\n                dup |= a & (1 << (c - \'a\'));\n                a |= 1 << (c - \'a\');\n            }\n            if (dup > 0) continue;\n            for (int i = dp.size() - 1; i >= 0; --i) {\n                if ((dp.get(i) & a) > 0) continue;\n                dp.add(dp.get(i) | a);\n                res = Math.max(res, Integer.bitCount(dp.get(i) | a));\n            }\n        }\n        return res;\n    }\n```
[]