c++ || bitmask and prefix sum and hashmaps
\n# Code\n\nclass Solution {\n//find string having even parity for each character + \n//string having at most one odd parity\n\n//find longest length of such st
\n# Code\n```\nclass Solution {\n//find string having even parity for each character + \n//string having at most one odd parity\n\n//find longest length of such string so we store smallest index for mask in dp[mask];\n\npublic:\n    int longestAwesome(string s) {\n        int res = 0, mask = 0;\n        int n = s.length();\n        //dp[i] = min index for the prefix having parity corrosponding to i(mask);\n        vector<int> dp(1024, 200000);\n        dp[0] = -1;\n        for(int i=0;i<n; i++){\n            mask = mask ^ (1<<(s[i]-\'0\'));\n            //check for the mask containig even no. of items;\n            res = max(res, i-dp[mask]);\n            //cehck for the mask containing all  even no. of items except one;\n            for(int j=0; j<=9; j++){\n                int newmask = mask^(1<<j);\n                res = max(res, i-dp[newmask]);\n            }\n            dp[mask] = min(dp[mask], i);\n        }\n        return res;\n    }\n};\n```
['Hash Table', 'String', 'Bit Manipulation', 'C++']