Check if 2 * K + 1 non | C # program for the above approach ; Function to check if the string S can be obtained by ( K + 1 ) non - empty substrings whose concatenation and concatenation of the reverse of these K strings ; Stores the size of the string ; If n is less than 2 * k + 1 ; Stores the first K characters ; Stores the last K characters ; Reverse the string ; If both the strings are equal ; Driver Code
using System ; class GFG { static void checkString ( string s , int k ) { int n = s . Length ; if ( 2 * k + 1 > n ) { Console . Write ( " No " ) ; return ; } string a = s . Substring ( 0 , k ) ; string b = s . Substring ( n - k , k ) ; char [ ] arr = b . ToCharArray ( ) ; Array . Reverse ( arr ) ; b = new String ( arr ) ; if ( a == b ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } public static void Main ( ) { string S = " qwqwq " ; int K = 1 ; checkString ( S , K ) ; } }