Count of unique digits in a given number N | Function that returns the count of unique digits of the given number ; Initialize a variable to store count of unique digits ; Initialize cnt list to store digit count ; Iterate through the digits of N ; Retrieve the last digit of N ; Increase the count of the last digit ; Remove the last digit of N ; Iterate through the cnt list ; If frequency of digit is 1 ; Increment the count of unique digits ; Return the count of unique digit ; Given number N ; Function call
def countUniqueDigits ( N ) : NEW_LINE INDENT res = 0 NEW_LINE cnt = [ 0 ] * 10 NEW_LINE while ( N > 0 ) : NEW_LINE INDENT rem = N % 10 NEW_LINE cnt [ rem ] += 1 NEW_LINE N = N // 10 NEW_LINE DEDENT for i in range ( 10 ) : NEW_LINE INDENT if ( cnt [ i ] == 1 ) : NEW_LINE INDENT res += 1 NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT N = 2234262 NEW_LINE print ( countUniqueDigits ( N ) ) NEW_LINE