#K88577. Beautify the String
Beautify the String
Beautify the String
You are given a string s
consisting of only lowercase English letters. Your task is to transform this string into a beautiful string by ensuring that no two adjacent characters are identical. In other words, if s[i] == s[i+1]
for any valid index i
, you must change s[i+1]
to some other letter, using as few changes as possible.
For example:
- For
s = "aab"
, an optimal transformation would yield"aba"
. - For
s = "aaabb"
, one valid output is"ababa"
. - If the string is already beautiful, such as
s = "abcd"
, no changes are needed.
Your solution should read an input from standard input (stdin) and output the result to standard output (stdout).
inputFormat
The input consists of a single line containing a string s
(with length at most 100,000) composed of lowercase English letters.
outputFormat
Output a single line: the transformed beautiful string where no two adjacent characters are the same, achieved with the fewest changes possible.
## samplea
a