Lexicographically smallest numeric string having odd digit counts | C # program for the above approach ; Function to construct lexicographically smallest numeric string having an odd count of each characters ; Stores the resultant string ; If N is even ; Otherwise ; Driver code
using System ; class GFG { static string genString ( int N ) { string ans = " " ; if ( N % 2 == 0 ) { for ( int i = 0 ; i < N - 1 ; i ++ ) ans += '1' ; ans += '2' ; } else { for ( int i = 0 ; i < N ; i ++ ) ans += '1' ; } return ans ; } public static void Main ( ) { int N = 5 ; Console . WriteLine ( genString ( N ) ) ; } }