C++ solution | Bit manipulation and Hashmaps | Explanation
\n\n\n\n\n```\nclass Solution {\npublic:\n    int longestAwesome(string s) {\n        unordered_mapmaskTable;\n        maskTable[0]=-1;\n        int ans=0;\n   
![image](https://assets.leetcode.com/users/images/99e88436-7a7e-4309-97ac-55108293a6ac_1656577255.5991323.jpeg)\n![image](https://assets.leetcode.com/users/images/82940c6e-3c42-4eca-b3d2-444ba0663d11_1656577267.6991522.jpeg)\n![image](https://assets.leetcode.com/users/images/4adff6e6-77b6-4987-9b99-0ebcb0c144c7_1656577286.23025.jpeg)\n![image](https://assets.leetcode.com/users/images/153f279b-d4f8-4b3c-bfc9-02b3e48c7c98_1656577299.7385113.jpeg)\n![image](https://assets.leetcode.com/users/images/f49ec115-14a4-41ec-958f-29b9adbf1ab3_1656577324.9608977.jpeg)\n```\nclass Solution {\npublic:\n    int longestAwesome(string s) {\n        unordered_map<int,int>maskTable;\n        maskTable[0]=-1;\n        int ans=0;\n        int mask=0;\n        for(int i=0;i<s.size();i++){\n            int digit=s[i]-\'0\';\n            mask^=(1<<digit);\n            if(!maskTable.count(mask)){\n                maskTable[mask]=i;\n            } else {\n                //case III\n                ans=max(ans,i-maskTable[mask]);\n            }\n            //caseI and case II\n            if(mask==0 or (mask&(mask-1))==0){\n                ans=max(ans,i+1);\n            }\n            //case IV\n            for(int pos=0;pos<=10;pos++){\n                int nwmask=mask^(1<<pos);\n                if(maskTable.count(nwmask)){\n                    ans=max(ans,i-maskTable[nwmask]);\n                }\n            }\n        }\n        return ans;\n    }\n};
['Bit Manipulation', 'C', 'Bitmask', 'C++']