#C7077. Make Diverse String
Make Diverse String
Make Diverse String
Problem Description:
Given a string s consisting of lowercase English letters, your task is to transform it into a diverse string. A diverse string is defined as a string in which no two adjacent characters are identical. To achieve this, you may insert additional characters into the string. However, you must insert the minimum possible characters such that the relative order of the original characters is maintained.
You are allowed to insert any lowercase letter between characters, but the inserted character must not be the same as its neighbor (either the character before or after it) in the resulting string.
Note: If the string is already diverse, no insertions are required. Use a greedy strategy to perform the necessary insertions.
Example:
Input: aabb One valid output: ababab
inputFormat
A single line containing a non-empty string s of lowercase letters.
outputFormat
Output the transformed diverse string on a single line.## sample
aabb
ababab