Easy bitmask with explanation O(n)
We store the first occurance of counts in a mask\nfor all even we do\nmask[i] = set digit\'th bit if count[digit] in 1..i is odd\n\nans = i \u2013 start[mask]\n
We store the first occurance of counts in a mask\nfor all even we do\n`mask[i]` = set `digit\'th` bit if `count[digit]` in `1..i` is odd\n\n`ans = i \u2013 start[mask]`\nfor only one odd (digit = `b`)\nwe find `new mask`\n`new_mask = mask ^ (1<<b)`\n`ans = i \u2013 start[new_mask]`\n\nps we only do this when we have seen atleast one occourance of the mask\n\ncode:\n```\n    int longestAwesome(string s) {\n\n        int n = s.length();\n        int ans = 1;\n        int mask = 0;\n        vector<int> pos(2000, -1);\n        pos[0] = 0;\n        for (int i = 1; i <= n; i++)\n        {\n            int d = s[i-1] - \'0\';\n            mask ^= 1<<d;\n            if (pos[mask] == -1)\n                pos[mask] = i;\n\t\t\t\t\n\t\t\t // for no odd digit in subarray\n            ans = max(ans, i - pos[mask]);\n\t\t\t// for only one odd digit in subarray\n            for (int b = 0; b < 10; b++)\n            {\n\t\t\t\t// only odd bit is b\n                int new_mask = mask^(1<<b);\n                if (pos[new_mask] != -1)\n                {\n                    ans = max(ans, i - pos[new_mask]);\n                }\n            }\n        }\n        return ans;\n    }\n```
['Bit Manipulation', 'Prefix Sum']