Number of strings which starts and ends with same character after rotations | C # program for the above approach ; Function to find the count of string with equal end after rotations ; To store the final count ; Traverse the string ; If current character is same as the previous character then increment the count ; Return the final count ; Driver Code ; Given string ; Function call
using System ; class GFG { static int countStrings ( String s ) { int cnt = 0 ; for ( int i = 1 ; i < s . Length - 1 ; i ++ ) { if ( s [ i ] == s [ i + 1 ] ) { cnt ++ ; } } return cnt ; } public static void Main ( String [ ] args ) { String str = " aacbb " ; Console . WriteLine ( countStrings ( str ) ) ; } }