Memoized DP
We recursively generate two strings string_a , string_b from s.\nIn this quetion at every index i of string s, we have 3 choices:\n1.add s[i] to string_a\n2.add
We recursively generate two strings string_a , string_b from s.\nIn this quetion at every index i of string s, we have 3 choices:\n1.add s[i] to string_a\n2.add s[i] to string_b\n3.Do not add s[i] to string_a or string_b\nWe take max of every 3 choices at every step.\nWhen we i == length of s, we check is string_a and string_b generated are palindrome. If palindrome, return product of the length of two strings else return 0\nOn careful observation it is found that recursively generated i,string_a, string_b are repeating and hence we memoize them.\n```\nmemo = {}\ndef is_palindrome(string):\n    (i,j) = (0,len(string)-1)\n    while i < j:\n        if string[i] != string[j]:\n            return False\n        i += 1\n        j -= 1\n    return True\ndef recurse(s,i,string_a,string_b):\n    global memo\n    if i >= len(s):\n        if is_palindrome(string_a) and is_palindrome(string_b):\n            return len(string_a) * len(string_b)\n        else:\n            return 0\n    elif (i,string_a,string_b) in memo:\n        return memo[(i,string_a,string_b)]\n    ans1 = recurse(s,i+1,string_a+ s[i],string_b)\n    ans2 = recurse(s,i+1,string_a,string_b+ s[i])\n    ans3 = recurse(s,i+1,string_a,string_b)\n    ans =  max(ans1,ans2,ans3)\n    memo[(i,string_a,string_b)] = ans\n    return ans\n        \nclass Solution:\n    def maxProduct(self, s: str) -> int:\n        global memo\n        memo = {}\n        return recurse(s,0,"","")\n```
[]