C++ | Hash Table | Bitmasking
\n# Code\n\nclass Solution {\npublic:\n    int longestAwesome(string s) {\n        int n = s.size();\n        unordered_map<int,int> m;\n        int mask = 0;\n
\n# Code\n```\nclass Solution {\npublic:\n    int longestAwesome(string s) {\n        int n = s.size();\n        unordered_map<int,int> m;\n        int mask = 0;\n        m[mask] = -1;\n        int ans = INT_MIN;\n        for(int i=0;i<n;i++)\n        {\n            mask^=(1<<(s[i]-\'0\'));\n            if(m.find(mask)!=m.end())\n            {\n                ans = max(ans,i-m[mask]);\n            }\n            for(int j=0;j<=9;j++)\n            {\n                int tmp = mask^(1<<j);\n                if(m.find(tmp)!=m.end())\n                ans = max(ans,i-m[tmp]);\n            }\n            if(m.find(mask)==m.end())\n            m[mask] = i;\n        }\n        if(ans==INT_MIN)\n        return 1;\n        return ans;\n    }\n};\n```
['Hash Table', 'Bit Manipulation', 'C++']