Python 3 || 5 lines, greedy  || T/S: 95% / 42%
Here\'s the plan:\n1. We generate all subsequences of s as lists of characters.\n\n2. We filter that list for palindromes.\n3. We compare each pair of palindrom
Here\'s the plan:\n1. We generate all subsequences of `s` as lists of characters.\n\n2. We filter that list for palindromes.\n3. We compare each pair of palindromes, first to see whether they are disjoint, and if so, determine the product of their lengths.\n4. We determine the maximum product and return it as the answer to the problem.\n```\nclass Solution:\n    def maxProduct(self, s: str) -> int:\n\n        n, d = len(s), defaultdict(int)\n\n        for mask in range(1<<n):                                # <-- 1\n            sub = [s[i] for i in range(n) if mask & (1<<i)]     #\n\n            if sub == sub[::-1]: d[mask] = len(sub)             # <-- 2\n\n        return max(d[mask1] * d[mask2] for mask1, mask2         # <-- 3\n                    in combinations(d,2) if mask1 & mask2 == 0) # <-- 4\n```\n[https://leetcode.com/problems/maximum-product-of-the-length-of-two-palindromic-subsequences/submissions/1342459895/](https://leetcode.com/problems/maximum-product-of-the-length-of-two-palindromic-subsequences/submissions/1342459895/)\n\nI could be wrong, but I think that time complexity is *O*(*N* * 2^ *N*) and space complexity is *O*(*N*^2), in which *N* ~ `len(s)`.\n\n\n\n
['Python3']