text: Minimum rotations required to get the same string | C # program to determine minimum number of rotations required to yield same string . ; Returns count of rotations to get the same string back . ; tmp is the concatenated string . ; substring from i index of original string size . ; if substring matches with original string then we will come out of the loop . ; Driver Method
code: using System ; class GFG { static int findRotations ( String str ) { String tmp = str + str ; int n = str . Length ; for ( int i = 1 ; i <= n ; i ++ ) { String substring = tmp . Substring ( i , str . Length ) ; if ( str == substring ) return i ; } return n ; } public static void Main ( ) { String str = " abc " ; Console . Write ( findRotations ( str ) ) ; } }