Find the size of largest group where groups are according to the xor of digits | Function to find out xor of digit ; Calculate xor digitwise ; Return xor ; Function to find the size of largest group ; Hash map for counting frequency ; Counting freq of each element ; Find the maximum ; Initialise N
def digit_xor ( x ) : NEW_LINE INDENT xorr = 0 NEW_LINE while ( x != 0 ) : NEW_LINE INDENT xorr ^= x % 10 NEW_LINE x = x // 10 NEW_LINE DEDENT return xorr NEW_LINE DEDENT def find_count ( n ) : NEW_LINE INDENT mpp = { } NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if digit_xor ( i ) in mpp : NEW_LINE INDENT mpp [ digit_xor ( i ) ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT mpp [ digit_xor ( i ) ] = 1 NEW_LINE DEDENT DEDENT maxm = 0 NEW_LINE for x in mpp : NEW_LINE INDENT if ( mpp [ x ] > maxm ) : NEW_LINE INDENT maxm = mpp [ x ] NEW_LINE DEDENT DEDENT return maxm NEW_LINE DEDENT N = 13 NEW_LINE print ( find_count ( N ) ) NEW_LINE