#K91082. Minimum Deletions to Make String Happy
Minimum Deletions to Make String Happy
Minimum Deletions to Make String Happy
Given a string s
of length n consisting only of the characters 'a' and 'b', your task is to make the string happy by performing the minimum number of deletions. A string is considered happy if there are no two adjacent characters that are the same, i.e. for all indices \( i \) (with \( 1 \leq i < n \)), \( s_i \neq s_{i+1} \).
You need to compute the minimum number of deletions required to achieve this property.
inputFormat
The input is read from stdin
and consists of two lines:
- The first line contains an integer n which represents the length of the string.
- The second line contains the string
s
of length n, consisting only of characters 'a' and 'b'.
outputFormat
Output to stdout
a single integer, the minimum number of deletions required to make the string happy.
4
abab
0
</p>