Count of largest sized groups while grouping according to product of digits | Function to find out product of digit ; calculate product ; return the product of digits ; Function to find the count ; hash map for counting frequency ; counting freq of each element ; find the maximum ; count the number of groups having size of equal to largest group . ; initialise N
def digit_prod ( x ) : NEW_LINE INDENT prod = 1 NEW_LINE while ( x ) : NEW_LINE INDENT prod = prod * ( x % 10 ) NEW_LINE x = x // 10 NEW_LINE DEDENT return prod NEW_LINE DEDENT def find_count ( n ) : NEW_LINE INDENT mpp = { } NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT x = digit_prod ( i ) NEW_LINE if x in mpp : NEW_LINE INDENT mpp [ x ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT mpp [ x ] = 1 NEW_LINE DEDENT DEDENT ans = 1 NEW_LINE maxm = 0 NEW_LINE for value in mpp . values ( ) : NEW_LINE INDENT if ( value > maxm ) : NEW_LINE INDENT maxm = value NEW_LINE ans = 1 NEW_LINE DEDENT elif ( value == maxm ) : NEW_LINE INDENT ans = ans + 1 NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT N = 13 NEW_LINE print ( find_count ( N ) ) NEW_LINE