If adjacent character are same then increase counter
if ( S [ i ] == S [ i + 1 ] ) c += 1 ; else { p . Add ( c ) ; c = 1 ; } p . Add ( c ) ; } if ( p . Count == 1 ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; }