Print all unique digits present in concatenation of all array elements in the order of their occurrence | Function to print long unique elements ; Reverse the list ; Traverse the list ; Function which check for all unique digits ; Stores the final number ; Stores the count of unique digits ; Converting string to long longer to remove leading zeros ; Stores count of digits ; Iterate over the digits of N ; Retrieve the last digit of N ; Increase the count of the last digit ; Remove the last digit of N ; Converting string to long longer again ; Iterate over the digits of N ; Retrieve the last digit of N ; If the value of this digit is not visited ; If its frequency is 1 ( unique ) ; Mark the digit visited ; Remove the last digit of N ; Passing this list to print long the reversed list ; Function to concatenate array elements ; Stores the concatenated number ; Traverse the array ; Convert to equivalent string ; Concatenate the string ; Passing string to checkUnique function ; Driver Code ; Function call to print long unique digits present in the concatenation of array elements
function printUnique ( lis ) { lis . reverse ( ) ; for ( var i = 0 ; i < lis . length ; i ++ ) { document . write ( lis [ i ] + " " ) } } function checkUnique ( st ) { var lis = [ ] ; var res = 0 ; var N = parseInt ( st ) ; var cnt = Array ( 10 ) . fill ( 0 ) ; var cnt1 = Array ( 10 ) . fill ( 0 ) ; while ( N > 0 ) { var rem = N % 10 ; cnt [ rem ] += 1 ; N = parseInt ( N / 10 ) ; } N = parseInt ( st ) ; while ( N > 0 ) { var rem = N % 10 ; if ( cnt1 [ rem ] == 0 ) { if ( cnt [ rem ] == 1 ) lis . push ( rem ) ; } cnt1 [ rem ] = 1 ; N = parseInt ( N / 10 ) ; } printUnique ( lis ) ; } function combineArray ( lis ) { var st = " " ; for ( var i = 0 ; i < lis . length ; i ++ ) { var ee = ( lis [ i ] . toString ( ) ) ; st = st + ee ; } checkUnique ( st ) ; } var arr = [ 122 , 474 , 612 , 932 ] ; combineArray ( arr ) ;