C++ || Recursion + Backtracking || Easy To Understand ✔
\nclass Solution {\npublic:\n\tint ans = 0;\n\tint n;\n\t//function for checking is given string is Palindrome\n\tbool palindrome(string s)\n\t{\n\t\tint i = 0;
```\nclass Solution {\npublic:\n\tint ans = 0;\n\tint n;\n\t//function for checking is given string is Palindrome\n\tbool palindrome(string s)\n\t{\n\t\tint i = 0;\n\t\tint j = s.size() - 1;\n\t\twhile (i <= j)\n\t\t{\n\t\t\tif (s[i++] != s[j--])\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tvoid solve(int index, string &s, string &s1, string &s2)\n\t{\n\t\t//If index >= n (where n = s.size()) then return\n\t\tif (index >= n)\n\t\t{\n\t\t\t//If both s1 and s2 are palindrome then this is as required in problem\n\t\t\t//so update ans with ans = max(ans, s1.size() * s2.size());\n\t\t\tif (palindrome(s1) && palindrome(s2))\n\t\t\t{\n\t\t\t\tans = max(ans, (int)s1.size() * (int)s2.size());\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t//1. include s[index]\n\t\t\t//1.(i) adding s[index] in string s1\n\t\t\ts1.push_back(s[index]);\n\t\t\tsolve(index + 1, s, s1, s2);\n\t\t\ts1.pop_back();\n\t\t\t//1.(ii) adding s[index] in string s2\n\t\t\ts2.push_back(s[index]);\n\t\t\tsolve(index + 1, s, s1, s2);\n\t\t\ts2.pop_back();\n\n\t\t//2. not including s[index] in string generation\n\t\tsolve(index + 1, s, s1, s2);\n\t}\n\n\tint maxProduct(string s) {\n\t\tint index = 0;\n\t\tn = s.size();\n\t\tstring s1 = "";\n\t\tstring s2 = "";\n\t\tsolve(index, s, s1, s2);\n\t\treturn ans;\n\t}\n};\n```\n\n**If find Helpful *Upvote It* \uD83D\uDC4D**
['Backtracking', 'Recursion', 'C']