<p>You are given a string <code>s</code>. An <strong>awesome</strong> substring is a non-empty substring of <code>s</code> such that we can make any number of swaps in order to make it a palindrome.</p>

<p>Return <em>the length of the maximum length <strong>awesome substring</strong> of</em> <code>s</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;3242415&quot;
<strong>Output:</strong> 5
<strong>Explanation:</strong> &quot;24241&quot; is the longest awesome substring, we can form the palindrome &quot;24142&quot; with some swaps.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;12345678&quot;
<strong>Output:</strong> 1
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;213123&quot;
<strong>Output:</strong> 6
<strong>Explanation:</strong> &quot;213123&quot; is the longest awesome substring, we can form the palindrome &quot;231132&quot; with some swaps.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
	<li><code>s</code> consists only of digits.</li>
</ul>

class Solution:
    def longestAwesome(self, s: str) -> int:
        #palindrome == at most one odd char
        bits = 0
        hashed_map = [-1] * 2048 #(2^11-1)
        ans = 0
        for i in range(len(s)):
            bits^=2**(int(s[i]))
            print(str(i).zfill(2),bin(bits).rjust(13,'0'))
            if bits ==0:
                ans = i+1
            else:
                if bin(bits).count('1') < 2:
                    ans = i+1
                else: 
                    if hashed_map[bits] != -1:
                        ans = max(ans,i+1-hashed_map[bits])
                    for j in range(10):
                        temp =2**j & bits
                        if temp !=0:
                            if hashed_map[bits-2**j] != -1:
                                #print(i,bin(bits),bin(bits-2**j),hashed_map[bits-2**j])
                                ans = max(ans,i+1-hashed_map[bits-2**j])
                        else:
                            if hashed_map[bits+2**j] != -1:
                                #print(i,bin(bits),bin(bits-2**j),hashed_map[bits-2**j])
                                ans = max(ans,i+1-hashed_map[bits+2**j])
                if hashed_map[bits] == -1:
                    hashed_map[bits] = i+1
        return ans            


17700