c++ | easy | short
\n\n# Code\n\nclass Solution {\npublic:\n   int longestAwesome(string s) {\n    vector<int> dp(1024, s.size());\n    int res = 0, mask = 0;\n    dp[0] = -1;\n  
\n\n# Code\n```\nclass Solution {\npublic:\n   int longestAwesome(string s) {\n    vector<int> dp(1024, s.size());\n    int res = 0, mask = 0;\n    dp[0] = -1;\n    for (auto i = 0; i < s.size(); ++i) {\n        mask ^= 1 << (s[i] - \'0\');\n        res = max(res, i - dp[mask]);\n        for (auto j = 0; j <= 9; ++j)\n            res = max(res, i - dp[mask ^ (1 << j)]);\n        dp[mask] = min(dp[mask], i);\n    }\n    return res;\n}\n};\n```
['C++']