Check if a string follows a ^ nb ^ n pattern or not | C # code to check a ^ nb ^ n pattern ; Returns " Yes " str is of the form a ^ nb ^ n . ; check first half is ' a ' and other half is full of ' b ' ; Driver code ; Function call
using System ; public class GFG { static string isAnBn ( string str ) { int n = str . Length ; if ( ( n & 1 ) != 0 ) return " No " ; int i ; for ( i = 0 ; i < n / 2 ; i ++ ) if ( str [ i ] != ' a ' str [ n - i - 1 ] != ' b ' ) return " No " ; return " Yes " ; } static public void Main ( ) { string str = " ab " ; Console . WriteLine ( isAnBn ( str ) ) ; } }