#K42917. Replacing Question Marks to Avoid Consecutive Duplicates
Replacing Question Marks to Avoid Consecutive Duplicates
Replacing Question Marks to Avoid Consecutive Duplicates
You are given a string s
consisting of lowercase letters and question mark characters ('?'). Your task is to replace every '?' with one of the letters 'a', 'b', or 'c' so that no two adjacent characters in the resulting string are identical.
If the string does not contain any '?', simply output it unchanged. It is guaranteed that a valid replacement always exists.
The input is provided via standard input (stdin) and the output should be sent to standard output (stdout).
inputFormat
A single line containing the string s
composed of lowercase letters and '?' characters.
outputFormat
A single line with the modified string where every '?' is replaced by one of the letters 'a', 'b', or 'c' ensuring that no two adjacent characters are the same.## sample
a?b?c?d
acbacad