JS - slow but simple (without bitmask)
Only possible since s.length <= 12 and we can basically check every possible variant.\n\nBased on this Python solution:\nhttps://leetcode.com/problems/maximum-p
Only possible since s.length <= 12 and we can basically check every possible variant.\n\nBased on this Python solution:\nhttps://leetcode.com/problems/maximum-product-of-the-length-of-two-palindromic-subsequences/discuss/1458751/Python-DFS-solution\n\n```\nconst isPalindrome = (str) => {\n    for (let i = 0, j = str.length - 1; i < j; i++, j--) {\n        if (str[i] !== str[j]) return false;\n    }\n    return true;\n}\n\nfunction maxProduct(s) {\n    function cb(letterIndex, word1, word2) {\n        if (letterIndex > s.length) {\n            return isPalindrome(word1) && isPalindrome(word2)\n                ? word1.length * word2.length\n                : 0;\n        }\n        \n        const char = s[letterIndex];\n        const newIndex = letterIndex + 1;\n        \n        return Math.max(\n            cb(newIndex, word1, word2),\n            cb(newIndex, `${word1}${char}`, word2),\n            cb(newIndex, word1, `${word2}${char}`)\n        );\n    }\n    \n    return cb(0, \'\', \'\');\n};\n```
['JavaScript']