Simple Explanation of the idea using bitmasking
If the subtring S[j....i] is making a palindrome then the XOR of this substring will be either 0(in case of even length palindrome) or only one of the 10 bit wi
If the subtring S[j....i] is making a palindrome then the XOR of this substring will be either 0(in case of even length palindrome) or only one of the 10 bit will be set(in case of odd length palindrome)\n\n1.In case of even length palindromic S[j.....i] is a palindromic substring then XOR(S[0....j-1]) and XOR(S[0....i]) should be the same  since XOR(S[j...i]) is zero.\nSo we can use dp to get the last location we found the same XOR.\n2.Similarly for odd length palindrome we can try setting each of the 10 bits and see if we got the same xor earlier.\n\n```\nclass Solution {\npublic:\n    int longestAwesome(string s)\n    {\n        int n=s.length();\n        vector<int> last(1025,n);//To store the last position of xor\n        \n        last[0]=-1;\n        \n        int ans=0,cur=0;\n        \n        for(int i=0;i<n;i++)\n        {\n            cur^= 1<<(s[i]-\'0\');\n            ans=max(ans,i-last[cur]);//suppose the last time curr mask was occured at jth position\n                    //then xor of j.....i should be 0\n            \n            for(int j=0;j<10;j++)\n            {\n                ans=max(ans,i-last[cur ^ (1<<j)]);//if the palindrome is of odd length\n            }\n            last[cur]=min(last[cur],i);//The last location for which i found this mask\n        }\n             \n        return ans;\n    }\n};\n\n```\nPlease **Upvote** if you found this helpful.Any **Suggestions** are welcome
['C', 'Bitmask']