Can Anyone help me. Please explain the question i cant get it and logic behind it.

String ( 2 loop based problem)

Given a string, look for a mirror image (backwards) string at both the beginning and end of the given string. In other words, zero or more characters at the very begining of the given string, and at the very end of the string in reverse order (possibly overlapping). For example, the string "abXYZba" has the mirror end "ab".

mirrorEnds("abXYZba") → "ab"
mirrorEnds("abca") → "a"
mirrorEnds("aba") → "aba"
gnanagowthaman sankarAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
HI,

if you begin from the start of the string and the end of the string what are the same characters
mirrorEnds("abXYZba") "abXYZba" → "abXYZba" → "ab"
mirrorEnds("abca") "abca" → "a"
mirrorEnds("aba") → "aba"→ "aba"→ "aba"→ "aba"
bold from the start italic from the end

Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rrzCommented:
The word "mirror" is confusing. If you used an actual mirror, you would not be able to read the characters. I think the word "backwards" is a better description.  If the first character equals the last character, then add it to the result. If the second character from the beginning equals the second character from the end, then add that to the result.  You can continue doing that comparison until you find a mismatch.  You could write the code just like that.
0
Shaun VermaakTechnical SpecialistCommented:
You need to do two loops, one from the first character to last and one from last to first.
Do this and build string until the character in the two loops do not match anymore
0
mccarlIT Business Systems Analyst / Software DeveloperCommented:
You would definitely NOT need two loops. You only need one loop, and at each iteration of that one loop you check two characters, but it is still only one loop.
0
Shaun VermaakTechnical SpecialistCommented:
I am only saying that in the context "2 loop based problem"
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.