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 array 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 array ; If frequency of digit is 1 ; Increment the count of unique digits ; Return the count / of unique digit ; Given array arr [ ] ; Function Call
function countUniqueDigits ( N ) { let res = 0 ; let cnt = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ; while ( N > 0 ) { let rem = N % 10 ; cnt [ rem ] ++ ; N = Math . floor ( N / 10 ) ; } for ( let i = 0 ; i < 10 ; i ++ ) { if ( cnt [ i ] == 1 ) { res ++ ; } } return res ; } let N = 2234262 ; document . write ( countUniqueDigits ( N ) ) ;