[C++] Bitmask + Hashmap
\nclass Solution {\npublic:\n    int longestAwesome(string s) {\n        unordered_map<int, int>where;\n        int cur=0;\n        where[cur] = -1;\n        in
```\nclass Solution {\npublic:\n    int longestAwesome(string s) {\n        unordered_map<int, int>where;\n        int cur=0;\n        where[cur] = -1;\n        int n=s.size();\n        int ans=0;\n        for(int i=0; i<n; i++){\n            int dig = s[i]-\'0\';\n            cur^=(1<<dig); //flip \'dig\' bit\n            \n            if(where.find(cur)!=where.end())\n                ans = max(ans, i-where[cur]); //all even characters\n            \n            for(int bit = 0; bit<10; bit++){\n                int better = cur^(1<<bit); //allowing the \'bit\' bit to be odd in the substring\n                if(where.find(better)!=where.end())\n                    ans = max(ans, i-where[better]); //one odd, others even\n            }\n            \n            if(where.find(cur)==where.end())\n                where[cur]=i;\n        }\n        return ans;\n    }\n};\n```
['Bitmask']