#C9082. Minimum Replacements to Create a Happy String
Minimum Replacements to Create a Happy String
Minimum Replacements to Create a Happy String
You are given a string s
consisting of lowercase English letters. A happy string is defined as a string in which no two adjacent characters are the same, i.e. for every valid index i, the condition $$s_i \neq s_{i+1}$$ holds.
Your task is to determine the minimum number of character replacements required to convert the given string into a happy string. In each replacement, you can change the character at any position to any other lowercase letter, provided that the modified character does not cause two identical adjacent characters.
For example, given the string "aaabbc", the minimum number of replacements required is 2.
inputFormat
The input consists of a single line containing the string s
(1 ≤ |s| ≤ 104), which is composed of lowercase English letters.
outputFormat
Output a single integer representing the minimum number of replacements needed to convert s
into a happy string.
a
0