Utility compare
static int CompareTo ( String s1 , String s2 ) { for ( int i = 0 ; i < s1 . Length < s2 . Length ; i ++ ) { if ( s1 [ i ] < s2 [ i ] ) return - 1 ; else if ( s1 [ i ] > s2 [ i ] ) return 1 ; } return 0 ; } static void getSmallestAndLargest ( String s , int k ) {