Function to return the count of sub - strings starting from startIndex that are also the prefixes of str
int subStringsStartingHere ( string str , int n , int startIndex ) { int count = 0 , i = 1 ; while ( i <= n ) { if ( str . substr ( 0 , i ) == str . substr ( startIndex , i ) ) { count ++ ; } else break ; i ++ ; } return count ; }