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

We'll say that a "mirror" section in an array is a group of contiguous elements such that somewhere in the array, the same group appears in reverse order. For example, the largest mirror section in {1, 2, 3, 8, 9, 3, 2, 1} is length 3 (the {1, 2, 3} part). Return the size of the largest mirror section found in the given array.

maxMirror([1, 2, 3, 8, 9, 3, 2, 1]) → 3
maxMirror([1, 2, 1, 4]) → 3
maxMirror([7, 1, 2, 9, 7, 2, 1]) → 2
gnanagowthaman sankarAsked:
Who is Participating?

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

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.

My way (which may not be the most efficient way), would be to mirror the array, loop and then take all lengths possible, and find if that piece is to be found in the mirrored length.

var found_length = 0
loop i=1 to mirror.length
   loop j=1 to (mirror.length - i)
      'take the contiguous j is starting point, i is length, match if it's found in mirror_array
           if found and andalso  j > found_length then found_length = j
gnanagowthaman sankarAuthor Commented:
maxMirror([1, 2, 1, 4]) → 3   How 3 elements here 121 or 214 or 412 is not in sequence but how 3 elements
but how 3 elements

There are not "3 elements". The question is asking you to return the *length* of the longest contiguous and contiguously mirrorable sequence of array elements.

The answer is 3 there, because it is arrived at from the length of 121, (which is 3 of course), and which happens to be a palindromic number (it's the same backwards), so that qualifies it as being there  more than once. It's a mirror of itself.

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
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

From novice to tech pro — start learning today.