#C8036. Minimum Modifications for Distinct Adjacent Characters
Minimum Modifications for Distinct Adjacent Characters
Minimum Modifications for Distinct Adjacent Characters
You are given an integer \(n\) and a string \(s\) of length \(n\) consisting of lowercase English letters. Your task is to determine the minimum number of modifications required so that no two adjacent characters are identical.
In one modification, you can change any character to any other lowercase letter. Formally, for every index \(i\) where \(1 \leq i < n\), after making the modifications, the condition \(s_i \neq s_{i+1}\) must be satisfied.
Example:
- For \(s = \texttt{aabbb}\), the answer is \(3\). One optimal sequence of modifications is \(aabbb \to ababb \to ababa \to abcba\) (one possible solution).
inputFormat
The input is given in two lines. The first line contains an integer \(n\) (\(1 \leq n \leq 10^5\)) representing the length of the string. The second line contains the string \(s\) consisting of lowercase English letters.
outputFormat
Output a single integer, the minimum number of modifications needed to ensure that no two adjacent characters are equal.
## sample6
abcdef
0
</p>