C++ | Recursion + Memo | Simple
\n//YOUTUBE VIDEO : https://www.youtube.com/watch?v=MqMvkrkerIY\nclass Solution {\npublic:\n    bool hasCommon(string &s1, string& s2) {\n        int arr[26] = 
```\n//YOUTUBE VIDEO : https://www.youtube.com/watch?v=MqMvkrkerIY\nclass Solution {\npublic:\n    bool hasCommon(string &s1, string& s2) {\n        int arr[26] = {0};\n        \n        for(char &ch : s1) {\n            if(arr[ch-\'a\'] > 0)\n                return true;\n            arr[ch-\'a\']++;\n        }\n        \n        for(char &ch : s2) {\n            if(arr[ch-\'a\'] > 0)\n                return true;\n        }\n        \n        return false;\n    }\n    \n    unordered_map<string, int> mp;\n    \n    int solve(int idx, vector<string>& arr, string temp, int n) {\n        if(idx >= n)\n            return temp.length();\n        \n        if(mp.find(temp) != mp.end())\n            return mp[temp];\n        \n        int include = 0;\n        int exclude = 0;\n        if(hasCommon(arr[idx], temp)) {\n            exclude = solve(idx+1, arr, temp, n);\n        } else {\n            exclude = solve(idx+1, arr, temp, n);\n            temp += arr[idx];\n            include = solve(idx+1, arr, temp, n);\n        }\n        \n        return mp[temp] = max(include, exclude);\n    }\n    \n    int maxLength(vector<string>& arr) {\n        string temp = "";\n        mp.clear();\n        int n = arr.size();\n        \n        return solve(0, arr, temp, n);\n        \n    }\n};\n```
['Recursion', 'Memoization', 'C']