human
Length of the longest substring with every character appearing even number of times | Function to find length of the longest substring with each element occurring even number of times.
Initialize unordered_map.
Stores the length of the longest required substring.
Traverse the string.
Stores the value of the digit present at current index.
Bitwise XOR of the mask with 1 left - shifted by val.
Check if the value of mask is already present in ind or not.
Update the final answer.
Otherwise.
Return the answer.
Driver Code.
Given string.
: Length of the given string.
Function Call"
Solution in Python:
assistant
#Here is code to length of the longest substring with every character appearing even number of times and the other steps required.
 def lenOfLongestReqSubstr ( s , N ) :
	ind = { }
	mask = 0
	ind [ 0 ] = - 1
	ans = 0
	for i in range ( N ) :
		val = ord ( s [ i ] ) - ord ( '0' )
		mask ^= ( 1 << val )
		if ( mask in ind ) :
			ans = max ( ans , i - ind [ mask ] )
		else :
			ind [ mask ] = i
	return ans
if __name__ == " _ _ main _ _ " :
	s = "223015150"
	N = len ( s )
	print ( lenOfLongestReqSubstr ( s , N ) )