javascript bitmask brute force 1239ms
Main idea:\n(1) get all palindrome subsequence\n(2) parse all ways of picking two of them, if disjoint, max the product in result.\n\nconst isPalindrome = (s) =
Main idea:\n(1) get all palindrome subsequence\n(2) parse all ways of picking two of them, if disjoint, max the product in result.\n```\nconst isPalindrome = (s) => { let n = s.length; let i = 0; let j = n - 1; while (i < j) { if (s[i++] != s[j--]) return false; } return true; };\n\nconst maxProduct = (s) => {\n    let a = [];\n    let n = s.length;\n    let N = 2 ** n; // equal to 1 << n \n    for (let i = 0; i < N; i++) { // mask\n        let sub = \'\';\n        let idx = new Set();\n        for (let j = 0; j < n; j++) {\n            if (i & (1 << j)) {\n                sub += s[j];\n                idx.add(j);\n            }\n        }\n        if (isPalindrome(sub)) { // save all palindrome subsequence with index Set\n            a.push([sub, idx]);\n        }\n    }\n    let an = a.length;\n    let res = 0;\n    for (let i = 0; i < an; i++) {\n        for (let j = i + 1; j < an; j++) {\n            if (isDisjoint(a[i][0], a[j][0], a[i][1], a[j][1])) {\n                let len = a[i][0].length * a[j][0].length; // product\n                res = Math.max(res, len);\n            }\n        }\n    }\n    return res;\n};\n\nconst isDisjoint = (s, t, is, it) => { // two subsequence index Set should be different, no same index\n    for(const i of is) {\n        if (it.has(i)) return false;\n    }\n    return true;\n};\n```
['Bitmask', 'JavaScript']