Loop to store the count of continious characters in the given string
for ( var i = 1 ; i < n ; i ++ ) { if ( s . charAt ( i ) == s . charAt ( i - 1 ) ) cnt ++ ; else { v . push ( cnt ) ; cnt = 1 ; } } if ( cnt > 0 ) v . push ( cnt ) ;