Easy to Understand C++ solution !!
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int longestAwesome(string s) {
        int n = s.length();
        unordered_map<int,int> mp; //<mask, index>
        
        // Initializing with mask 0 at index -1 to handle full palindrome cases
        mp[0] = -1;
        
        int ans  = 0;
        int mask = 0;

        for(int i = 0; i < n; i++) {
            int dig = s[i] - '0'; // Convert character to integer digit
            
            // Toggle the bit corresponding to the digit
            mask = mask ^ (1 << dig);

            // Case 1: If the same mask has appeared before, it means the substring between those indices
            // has all even frequency digits (since XOR cancels out even counts)
            if(mp.find(mask) == mp.end()) {
                mp[mask] = i; // Store the first occurrence of this mask
            } else {
                ans = max(ans, i - mp[mask]); // Compute the max palindrome length from previous occurrence
            }
            
            // Case 2: If the mask is 0, it means all digits have even frequency so far, which means
            // the whole substring from 0 to i is a palindrome-like substring
            //
            // Case 3: If the mask has only one bit set (mask & (mask - 1) == 0), it means only one digit has odd frequency,
            // which can still form a palindrome-like structure
            if(mask == 0 || (mask & (mask - 1)) == 0) {
                ans = max(ans, i + 1); // Full valid palindrome substring
            }

            // Case 4: Check if changing any one bit (flipping any one digit’s frequency) results in a mask seen before.
            // This checks for the case where one digit has an odd count, and the rest have even counts.
            for(int pos = 0; pos < 10; pos++) {
                int newMask = mask ^ (1 << pos); // Flip bit at position `pos`
                if(mp.find(newMask) != mp.end()) {
                    ans = max(ans, i - mp[newMask]); // Compute max length using previous occurrence
                }
            }
        }
        return ans;
    }
};

['C++']