C++ (Backtrack : C++ users, please pass string by reference to PASS)
My YouTube Channel - https://www.youtube.com/@codestorywithMIK\n\n/*\nSimple explanation :\nif you notice I am trying all three possibilities :-\n\n    1) I pic
My YouTube Channel - https://www.youtube.com/@codestorywithMIK\n```\n/*\nSimple explanation :\nif you notice I am trying all three possibilities :-\n\n    1) I pick s[i] for s1 but don\'t pick s[i] for s2 (because they should be disjoint)\n       - I explore this path and find the result (and then backtrack)\n\n    2) I pick s[i] for s2 but don\'t pick s[i] for s1 (because they should be disjoint)\n        - I explore this path and find the result (and then backtrack)\n\n    3) I don\'t pick s[i] at all - I explore this path and find the result\n        (and then backtrack)\n\nIn any of the path, if I get s1 and s2 both as palindrome we update our\nresult with maximum length. It\'s like a classic Backtrack approach.\n*/\n```\n```\nclass Solution {\npublic:\n    int result = 0;\n    bool isPalin(string& s){\n        int i = 0;\n        int j = s.length() - 1;\n \n        while (i < j) {\n            if (s[i] != s[j]) return false;\n            i++;\n            j--;\n        }\n \n        return true;\n    }\n    \n    void dfs(string& s, int i, string& s1, string& s2){\n        \n        if(i >= s.length()){\n            if(isPalin(s1) && isPalin(s2))\n                result = max(result, (int)s1.length()*(int)s2.length());\n            return;\n        }\n        \n        s1.push_back(s[i]);\n        dfs(s, i+1, s1, s2);\n        s1.pop_back();\n        \n        s2.push_back(s[i]);\n        dfs(s, i+1, s1, s2);\n        s2.pop_back();\n        \n        dfs(s, i+1, s1, s2);\n    }\n    \n    int maxProduct(string s) {\n        string s1 = "", s2 = "";\n        dfs(s, 0, s1, s2);\n        \n        return result;\n    }\n};\n```
[]