✅C++ | ✅Use recursion | ✅Easy to Understand
\nclass Solution \n{\npublic:\n    \n    bool check(string &a, string &b)\n    {\n        vector<int> vis(26, 0);\n        for(auto it:a)\n            vis[it-\'
```\nclass Solution \n{\npublic:\n    \n    bool check(string &a, string &b)\n    {\n        vector<int> vis(26, 0);\n        for(auto it:a)\n            vis[it-\'a\']++;\n        \n\t\t//comparing each char of string a with every char of string b\n        for(int i=0; i<a.size(); i++)\n        {\n            if(vis[a[i]-\'a\'] > 1) return false; //check whether string a contains duplicate characters\n            for(int j=0; j<b.size(); j++)\n            {\n                if(a[i]==b[j]) return false; //check whether string a and b have same characters\n            }\n        }\n        return true;\n    }\n    \n    int f(int i, vector<string>& arr, string str)\n    {\n        if(i==0)\n        {\n            if(check(arr[0], str))\n                return arr[0].size();\n            return 0;\n        }\n        \n        int take=0, not_take=0;\n        \n        not_take = 0 + f(i-1, arr, str);\n        \n        if(check(arr[i], str))\n            take = arr[i].size() + f(i-1, arr, str+arr[i]);\n        \n        return max(not_take, take);\n    }\n    \n    int maxLength(vector<string>& arr) \n    {\n        return f(arr.size()-1, arr, "");\n    }\n};\n```
['Recursion', 'C', 'C++']