[Java] Prefix + Bitmask O(10*n)
Similar idea to https://leetcode.com/problems/find-the-longest-substring-containing-vowels-in-even-counts/\n\nBut additionally at each step we check for complem
Similar idea to https://leetcode.com/problems/find-the-longest-substring-containing-vowels-in-even-counts/\n\nBut additionally at each step we check for complements that add to power of two. Power of two since a palindrome can contain at most 1 odd number of characters.\n\n```\n    public int longestAwesome(String s) {\n        final Map<Integer, Integer> idx = new HashMap<>(Collections.singletonMap(0, -1));\n        int res = 0, mask = 0;\n        for (int i = 0; i < s.length(); i++) {\n            mask ^= 1 << (s.charAt(i) - \'0\');\n            idx.putIfAbsent(mask, i);\n            res = Math.max(res, i - idx.getOrDefault(mask, i));\n            for (int value = 1; value <= (1 << 10); value <<= 1) {\n                final int complement = value ^ mask;\n                res = Math.max(res, i - idx.getOrDefault(complement, i));\n            }\n        }\n        return res;\n    }\n```
[]