Numbers having Unique ( or Distinct ) digits | C # code for the above approach ; 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 ; Driver Code ; Input of the lower and higher limits ; Function Call
using System ; using System . Collections . Generic ; class GFG { static void printUnique ( int l , int r ) { for ( int i = l ; i <= r ; i ++ ) { String s = String . Join ( " " , i ) ; HashSet < int > uniDigits = new HashSet < int > ( ) ; foreach ( int c in s . ToCharArray ( ) ) uniDigits . Add ( c ) ; if ( s . Length == uniDigits . Count ) { Console . Write ( i + " ▁ " ) ; } } } public static void Main ( String [ ] args ) { int l = 1 , r = 20 ; printUnique ( l , r ) ; } }