[Python3] bitmask dp
Please check out this commit for solutions of weekly 258. \n\nclass Solution:\n    def maxProduct(self, s: str) -> int:\n        \n        @cache\n        def l
Please check out this [commit](https://github.com/gaosanyong/leetcode/commit/0de189059bd6af4dabe23d9066dde1655f3334fc) for solutions of weekly 258. \n```\nclass Solution:\n    def maxProduct(self, s: str) -> int:\n        \n        @cache\n        def lps(mask): \n            """Return length of longest palindromic sequence."""\n            if not mask: return 0\n            if not mask & (mask-1): return 1\n            lo = int(log2(mask & ~(mask-1))) # least significant set bit\n            hi = int(log2(mask)) # most significant set bit \n            if s[lo] == s[hi]: return 2 + lps(mask^(1<<lo)^(1<<hi))\n            return max(lps(mask^(1<<lo)), lps(mask^(1<<hi)))\n        \n        ans = 0\n        for mask in range(1 << len(s)): \n            comp = (1 << len(s)) - 1 ^ mask\n            ans = max(ans, lps(mask) * lps(comp))\n        return ans \n```
['Python3']