Explained Simple Efficient
A substring will be an awesome substring:-\n \xA0 \xA0 If the frequency of each digit/character is even in the substring\n\xA0 \xA0 Or\n \xA0 \xA0 If only one o
A substring will be an awesome substring:-\n* \xA0 \xA0 If the frequency of each digit/character is even in the substring\n\xA0 \xA0 Or\n* \xA0 \xA0 If only one of the digit/character is having odd count of frequency and rest of the ohters are having even frequency\n\xA0 \xA0 \n\xA0 \xA0 Here the possible character in the string are \'0\' to \'9\', so we can use a bitmap of length 10 where each position will have either 0 or 1\n\xA0 \xA0 If frequecy of digit \'0\' is even, then the first bit will be set as 0, or 1 otherwise\n\xA0 \xA0 If the frequency of digit \'1\' is even, then the second digit in bitmap will be 0, or 1 otherwise\n\xA0 \xA0 Same goese for digits 2,3,4....9 and 3rd,4th,5th....10th digit\n\xA0 \xA0 \n\xA0 \xA0 Now we will try to find substrings which are having even number of frequency for each digit or atmost 1 digit with odd frequency.\n\xA0 \xA0 For this we will use (digit-1)th bit in a bitmap\n\xA0 \xA0 When we process each digit, we will toggle the (digit-1)th position bit in bitmap.\xA0Toggeling this so it becomes 0 for even frequencies, and 1 for odd frequencies. \n\xA0 \xA0 Each time we will set the new bitmap in hashmap where bitmap will be key and the current index will be the value. \n\tBefore pushing this in hash, we will check if the same bitmap is already there in hasmap. If yes, then we know there has been a substring which has added even number of frequency for each digit, That\'s why the overall impact is nothing and we got the same bitmap again. That substring started from the last_index+1(We got last_index from hashmap) and ending on the current index.\n\tThe hashmap approach is similar to this, Refer to "Approach 4: Using Hashmap" here https://leetcode.com/problems/subarray-sum-equals-k/solution/\n\xA0 \xA0 The above thing covers all the substrings with even frequency of each digit\n\xA0 \xA0 \n\xA0 \xA0 Now to cover substring with odd frequency for 1 digit, we will follow below step\n\xA0 \xA0 There are 10 positions in the bitmap\n\xA0 \xA0 We will toggle the bit on 1st position and check if the toggled bitmap is there in hashmap, if yes then there is an awesome subtring starting after the value of hashmap till this index. It is becuase the substring in between these 2 indexes has added odd frequency only for 1 digit,\xA0rest of the other digits were added in even freqeuncy. That\'s why the current bitmap differs by 1 bit only.\n\xA0 \xA0 We will repeat the above step 10 times, each time we will toggle a new digit and check for the match.\n\xA0 \xA0 \n\tWhenever we find an awesome substring, we will check for the maximum length.\n\n```\n\tvar longestAwesome = function(s) {\n    let bitmap=0,hash={},digit,ans=0,d=1,toggledBitmap;\n    hash[0]=-1;\n    for(let i=0;i<s.length;i++){\n        digit = parseInt(s[i]);\n        bitmap^= 1<<digit;//Toggle digit bit in total bitmap. So if bit for digit 3 is already set then it will make it zero, otherwise it will set it to 1\n\t\t\n        if(hash[bitmap]!==undefined){//Here we are checking if the same bitmap has already been there\n            ans = Math.max(ans,i-hash[bitmap]);\n        }else{//***We are niw overriding the last key,value pair by the current one, this is to maximize the length whenever a match is found for any index on the right side. \n            hash[bitmap] = i;\n        }\n        for(let j=0;j<10;j++){//Here we are checking for bit with a difference of 1 bit. This is to cover the substrings having odd frequency for 1 digit. \n             d = 1<<j;\n            toggledBitmap = bitmap^d;\n            if(hash[toggledBitmap]!==undefined){\n                ans = Math.max(ans,i-hash[toggledBitmap]);\n            }\n        }\n    }\n    return ans;\n};\n```
[]