[C++] 100% time, 100%memory
\nclass Solution {\npublic:\n    int maxlen = 0;\n    void backtrack(vector<int>& maskArr, vector<int>& sizeArr, int mask, int len, int pos) {\n      if (pos ==
```\nclass Solution {\npublic:\n    int maxlen = 0;\n    void backtrack(vector<int>& maskArr, vector<int>& sizeArr, int mask, int len, int pos) {\n      if (pos == maskArr.size()) {\n        maxlen = max(len, maxlen);\n        return;\n      }\n      backtrack(maskArr, sizeArr, mask, len, pos + 1);\n      if ((mask & maskArr[pos]) == 0) {\n        backtrack(maskArr, sizeArr, mask | maskArr[pos], len + sizeArr[pos], pos + 1);\n      }\n    }\n\n    int maxLength(vector<string>& arr) {\n        vector<int> maskArr;\n        vector<int> sizeArr;\n        int i;\n        for (i = 0; i < arr.size(); i++) {\n            string s = arr[i];\n            int mask = 0;\n            for (char c : s) {\n                if (mask & (1 << (c - \'a\'))){\n                    mask = -1;\n                    break;\n                }\n                mask |= (1 << (c - \'a\'));\n            }\n            if (mask == -1)\n                continue;\n            maskArr.push_back(mask);\n            sizeArr.push_back(s.size());\n        }\n        backtrack(maskArr, sizeArr, 0, 0, 0);\n        return maxlen;\n    }\n};\n```
[]