1542. Find Longest Awesome Substring
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

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

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

# Code
```cpp []
class Solution {
public:
    int longestAwesome(string s) {
        int maxLen = 0, mask = 0;
        unordered_map<int, int> seen;
        seen[0] = -1;
        for (int i = 0; i < s.size(); ++i) {
            mask ^= (1 << (s[i] - '0'));
            if (seen.count(mask)) maxLen = max(maxLen, i - seen[mask]);
            else seen[mask] = i;
            for (int j = 0; j < 10; ++j) {
                int tempMask = mask ^ (1 << j);
                if (seen.count(tempMask)) maxLen = max(maxLen, i - seen[tempMask]);
            }
        }
        return maxLen;
    }
};

```
['C++']