We cancel the occurrence of a character if it occurs odd number times
mask2 = mask ^ ( 1 << j ) NEW_LINE if mask2 in index . keys ( ) : NEW_LINE INDENT answer = max ( answer , i - index [ mask2 ] ) NEW_LINE DEDENT return answer NEW_LINE