Question: You're given a string that contains only letters 'a' to 'z' and character '?'. Write an efficient algorithm that's replacing all characters '?' with letters
You're given a string that contains only letters 'a' to 'z' and character '?'. Write an efficient algorithm that's replacing all characters '?' with letters 'a' to 'z' in such a way, that return string doesn't contain adjacently repeating characters. You aren't allowed to change any character value or position in an input string except for the value of '?'. Presume that the input string doesn't contain adjacently repeating characters, except for '?'.
Example 1 Input: "?b?a" Output: "abca" (Other characters for '?' are valid as well, as long as output string is valid)
Example 2 Input: "ab?cde????fo??" Output: "abacdeabcdfode"
Example 3 Input: "??axzb??def??g" Output: "abaxzbcedefefg"
Example 4 Input: "??????????????" Output: "abcdefghijklmn"
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
