Question: code javascript: Replace all question marks in a given string to obtain a palindrome. Task description Write a function solution that, given a string S
code javascript: Replace all question marks in a given string to obtain a palindrome.
Task description
Write a function solution that, given a string S of length N returns any palindrome which can be obtained by replacing all of the question marks in S by lowercase letters az If no palindrome can be obtained, the function should return the string NO
A palindrome is a string that reads the same both forwards and backwards. Some examples of palindromes are: "kayak", "radar", "mom".
Examples:
Given S aba the function should return "aabbaa".
Given S "bab??a the function should return NO
Given S a the function may return "aaa". It may also return "zaz", among other possible answers.
Assume that:
N is an integer within the range ;
string S consists only of lowercases letters az or
In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
