Best Sol
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```cpp []\n\nclass Solution {\npublic:\n    int longestAwesome(string s) {\n        int n=s.length();\n        int mask=0;\n        int ans=0;\n        vector<int> M(1024,n);\n        M[0]=-1;\n        for(int i=0;i<n;i++){\n            mask^=(1<<(s[i]-\'0\'));\n            ans=max(ans,i-M[mask]);\n            for(int j=0;j<10;j++){\n                int flip=mask^(1<<j);\n                ans=max(ans,i-M[flip]);\n            }\n            M[mask]=min(M[mask],i); \n        }\n        return ans;\n    }   \n};\n```
['C++']