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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started