Simple python3 solution | Prefix XOR + DP
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1024) = O(1)\n Add your space complexity here, e.g. O(n
# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1024) = O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def longestAwesome(self, s: str) -> int:\n        bitmask = [\n            1 << i\n            for i in range(10)\n        ]\n\n        def get_pair_states(state):\n            yield state\n            for i in range(10):\n                yield state ^ (1 << i)\n\n        dp = {0: -1}\n        result = state = 0\n\n        for right, elem in enumerate(s):\n            state ^= bitmask[int(elem)]\n            for pair_state in get_pair_states(state):\n                if (left := dp.get(pair_state)) is not None:\n                    result = max(result, right - left)\n            if state not in dp:\n                dp[state] = right\n        \n        return result\n```
['Hash Table', 'Dynamic Programming', 'Bit Manipulation', 'Python3']