Bitmask || C++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int longestAwesome(string s) {\n        unordered_map<int,int>mp;  //mask->index\n        int mask=0,ans=0;\n        //string of is if length 0\n        mp[0]=-1;\n        for(int i=0;i<s.size();i++){\n            mask^=(1<<(s[i]-\'0\'));\n           \n           //if mask already exist\n           if(mp.count(mask)){\n               //if mask is present then calculate the maximum\n               ans=max(ans,i-mp[mask]);\n           }else{\n               mp[mask]=i;   //if msk does not exist then store its index\n           }\n\n           //for odd length the mask can differ by at most one bit\n           for(int j=0;j<10;j++){\n               if(mp.count(mask^(1<<j))){\n                   ans=max(ans,i-mp[mask^(1<<j)]);\n               }\n           }\n        }\n        return ans;\n    }\n};\n```
['Dynamic Programming', 'Bit Manipulation', 'C++']