BitMasking is easier than people think it is | No BackTraking
Code\n\nclass Solution {\npublic:\n    int memo(int i, vector<int>& nums, int mask){\n        if(i == nums.size()) return 0;\n        int pick = INT_MIN, nonPic
# Code\n```\nclass Solution {\npublic:\n    int memo(int i, vector<int>& nums, int mask){\n        if(i == nums.size()) return 0;\n        int pick = INT_MIN, nonPick = INT_MIN;\n        if((nums[i] & mask) == 0){\n            pick = __builtin_popcount(nums[i]) + memo(i+1,nums, mask | nums[i]);\n        }\n        nonPick = memo(i+1,nums, mask);\n        return max(pick, nonPick);\n    }\n    int maxLength(vector<string>& arr) {\n        vector<int>nums;\n        for(string s: arr){\n            int n  = 0;\n            bool flag = true;\n            for(int i = 0; i < s.size(); ++i){\n                if((n & (1 << (s[i] - \'a\'))) != 0){\n                    flag = false;\n                    break;\n                } \n                n |= (1 << (s[i] - \'a\'));\n            }\n            if(!flag) continue;\n            nums.push_back(n);\n        }\n        return memo(0,nums, 0);\n    }\n};\n```
['C++']