bitmask approach with O(n)
Intuition
Think about the prefix sum
Store the state in the dict and find the state when need
Approach
Don't care about the number of characters, we care about
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
- Think about the prefix sum
- Store the state in the dict and find the state when need

# Approach
<!-- Describe your approach to solving the problem. -->
- Don't care about the number of characters, we care about parity
- Call the mask (len 10) is the array present for the parity of the each number from 0-9 [0: even, 1:odd]

For each turn, we just modify the state of parity base in the current number, after that we can check it in 2 option
- the state that you wanna find fully even
- allow only 1 number odd in your state

Want to find the sub string that match with your desire state (the sub string will end with current location - i) just cut down the prefix sub that inverse state with your current state.

# Complexity
- Time complexity: $$O(n)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->


- Space complexity: $$O(n)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def longestAwesome(self, s: str) -> int:
        n = len(s)
        mask = {}
        cur_mask = 0b0000000000
        perfect_is_naaaaaa = 0b0000000000
        mask[cur_mask] = -1
        ans = 1
        for i in range(n):
            num = int(s[i])
            cur_mask ^= 1 << num
            need_mask = perfect_is_naaaaaa ^ cur_mask
            # all
            if need_mask in mask:
                ans = max(ans, i - mask[need_mask])
            # drop 1
            for bit in range(10):
                n_need_max = need_mask ^ (1 << bit)
                if n_need_max in mask:
                    ans = max(ans, i - mask[n_need_max])

            if cur_mask not in mask:
                mask[cur_mask] = i

        return ans
```
['Python3']