If the current character is different from the previous then include this character and update previous character
if ( prev != s . charAt ( i ) ) { prev = s . charAt ( i ) ; answer ++ ; } } return answer ; }