text: Find smallest possible Number from a given large Number with same count of digits | C # implementation of the above approach ; Function for finding the smallest possible number after swapping the digits any number of times ; Variable to store the readonly answer ; Array to store the count of occurrence of each digit ; Loop to calculate the number of occurrences of every digit ; Loop to get smallest number ; Returning the answer ; Driver code
code: using System ; class GFG { static String smallestPoss ( String s , int n ) { String ans = " " ; int [ ] arr = new int [ 10 ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ s [ i ] - 48 ] ++ ; } for ( int i = 0 ; i < 10 ; i ++ ) { for ( int j = 0 ; j < arr [ i ] ; j ++ ) ans = ans + String . Join ( " " , i ) ; } return ans ; } public static void Main ( String [ ] args ) { int N = 15 ; String K = "325343273113434" ; Console . Write ( smallestPoss ( K , N ) ) ; } }