Python bit mask
Since the string only contains digits, we can use 10 bits to represent the status of a substring, bit 1 indicates there is an odd number of digits, bit 0 indica
Since the string only contains digits, we can use 10 bits to represent the status of a substring, bit 1 indicates there is an odd number of digits, bit 0 indicates there is an even number of digits. So for an awesome substring, its status has to be zero (all the digits occur even number of times), or only one bit is 1 (there\'s only one digit occurs odd times)\n\n\n```\nclass Solution:\n    def longestAwesome(self, s: str) -> int:\n        left_most_masks = {0:-1}\n        valid_masks = {1 << i for i in range(10)} | {0}\n        ans = 0\n        curr_mask = 0\n        for i, x in enumerate(map(int, s)):\n            curr_mask ^= 1 << x\n            for valid_mask in valid_masks:\n                left_mask = valid_mask ^ curr_mask\n                if left_mask in left_most_masks:\n                    ans = max(ans, i - left_most_masks[left_mask])\n            if curr_mask not in left_most_masks:\n                left_most_masks[curr_mask] = i\n        return ans\n```
[]