text: Generate a string whose all K | C # program to generate a string whose substrings of length K concatenates to form given strings ; Function to return the required required string ; Iterate the given string ; Append the first character of every substring of length K ; Consider all characters from the last substring ; Driver code
code: using System ; class GFG { public static void decode_String ( String str , int K ) { String ans = " " ; for ( int i = 0 ; i < str . Length ; i += K ) ans += str [ i ] ; for ( int i = str . Length - ( K - 1 ) ; i < str . Length ; i ++ ) ans += str [ i ] ; Console . WriteLine ( ans ) ; } public static void Main ( String [ ] args ) { int K = 3 ; String str = " abcbcscsesesesd " ; decode_String ( str , K ) ; } }