Numbers having Unique ( or Distinct ) digits | Java implementation to find unique digit numbers in a range ; Method 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 method
class Test { static void printUnique ( int l , int r ) { for ( int i = l ; i <= r ; i ++ ) { int num = i ; boolean visited [ ] = new boolean [ 10 ] ; while ( num != 0 ) { if ( visited [ num % 10 ] ) break ; visited [ num % 10 ] = true ; num = num / 10 ; } if ( num == 0 ) System . out . print ( i + " ▁ " ) ; } } public static void main ( String args [ ] ) { int l = 1 , r = 20 ; printUnique ( l , r ) ; } }