Backtracking | explained solution | c++
just see the constraint for this question its very small so this signifies that this will be a backtracking question.\n\nlets assume my s1 will have the 1st pal
just see the constraint for this question its very small so this signifies that this will be a backtracking question.\n\nlets assume my s1 will have the 1st palindrome string and s2 will have the second one.\n\ni am finding the max of a,b,c where a denotes when i am not not adding any values.\nb denotes i am pushing value in s1 \nc denotes i am pushing value in s2;\n\nthe required answer will be the max of (a,b,c)\n\n\n\n\n```\n int palinlen (string &a)\n   {\n       int i=0;\n       int j=a.length()-1;\n       while(i<j)\n       {\n           if(a[i]!=a[j])return 0;\n           i++;\n           j--;\n       }\n       return a.length();\n   }\n    \n    \n    int helper(string &a,string &b,string &s,int i)\n    {\n        if(i>=s.length())return palinlen(a)*palinlen(b);\n        \n        int x=helper(a,b,s,i+1);\n        \n        a.push_back(s[i]);\n        int y=helper(a,b,s,i+1);\n        a.pop_back();\n        \n        b.push_back(s[i]);\n        int z=helper(a,b,s,i+1);\n        b.pop_back();\n        return max(x,max(y,z));\n        \n    }\n    int maxProduct(string s) {\n        string a="";\n        string b="";\n        return helper(a,b,s,0);\n    }\n```\n\n\nplease upvote if you liked my solution.\n#happy_coding
['Backtracking', 'C']