Numbers having Unique ( or Distinct ) digits | Function to print unique numbers ; Iterate from l to r ; Convert the no . to string ; Convert string to set using stl ; Output if condition satisfies ; Input of the lower and higher limits ; Function Call
function printUnique ( l , r ) { for ( let i = l ; i <= r ; i ++ ) { let s = String ( i ) ; let uniDigits = new Set ( ) ; for ( let c of s . split ( " " ) ) uniDigits . add ( c ) ; if ( s . length == uniDigits . size ) { document . write ( i + " " ) ; } } } let l = 1 , r = 20 ; printUnique ( l , r ) ;