Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Find the maximum possible length of a symmetric fragment which can be obtained after replacing question marks in a given string with <
Find the maximum possible length of a symmetric fragment which can be obtained after replacing question marks in a given string with or
Task description
A string made of an even number of characters andor is called symmetric if all characters in its first half are and all characters in its second half are Examples of symmetric strings are: empty string etc.
Write a function:
function solutionS;
that, given a string S made of N characters andor returns the length of the longest symmetric substring that can be obtained after replacing question marks with or characters.
Examples:
For S after replacing all question marks with the string is obtained. Its longest symmetric substring is so the function should return
For S the optimal option is to replace the first three question marks with and the next three question marks with thus obtaining the string The function should return
For S andor
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