If adjacent character are same then increase counter
if ( S [ i ] == S [ i + 1 ] ) c += 1 ; else { p . insert ( c ) ; c = 1 ; } p . insert ( c ) ; } if ( p . size ( ) == 1 ) cout << " Yes " << endl ; else cout << " No " << endl ; }