Numbers having Unique ( or Distinct ) digits | Function to print unique digit numbers in range from l to r . ; Start traversing the numbers ; Find digits and maintain its hash ; if a digit occurs more than 1 time then break ; num will be 0 only when above loop doesn 't get break that means the  number is unique so print it. ; Driver code
function printUnique ( l , r ) { for ( let i = l ; i <= r ; i ++ ) { let num = i ; let visited = new Array ( 10 ) ; while ( num ) { if ( visited [ num % 10 ] ) break ; visited [ num % 10 ] = true ; num = Math . floor ( num / 10 ) ; } if ( num == 0 ) document . write ( i + " " ) ; } } let l = 1 , r = 20 ; printUnique ( l , r ) ;