Print all unique digits present in concatenation of all array elements in the order of their occurrence | Function to print 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 integer 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 integer 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 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 unique digits present in the concatenation of array elements
def printUnique ( lis ) : NEW_LINE INDENT lis . reverse ( ) NEW_LINE for i in lis : NEW_LINE INDENT print ( i , end = " ▁ " ) NEW_LINE DEDENT DEDENT def checkUnique ( string ) : NEW_LINE INDENT lis = [ ] NEW_LINE res = 0 NEW_LINE N = int ( string ) 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 N = int ( string ) NEW_LINE while ( N > 0 ) : NEW_LINE INDENT rem = N % 10 NEW_LINE if ( cnt [ rem ] != ' visited ' ) : NEW_LINE INDENT if ( cnt [ rem ] == 1 ) : NEW_LINE INDENT lis . append ( rem ) NEW_LINE DEDENT DEDENT cnt [ rem ] = ' visited ' NEW_LINE N = N // 10 NEW_LINE DEDENT printUnique ( lis ) NEW_LINE DEDENT def combineArray ( lis ) : NEW_LINE INDENT string = " " NEW_LINE for el in lis : NEW_LINE INDENT el = str ( el ) NEW_LINE string = string + el NEW_LINE DEDENT checkUnique ( string ) NEW_LINE DEDENT arr = [ 122 , 474 , 612 , 932 ] NEW_LINE combineArray ( arr ) NEW_LINE