We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

aaabbb is not a palindrome, as aaabbb != bbbaaa. :)
Let me explain the approach a bit further.
Let's say we have a string abcxyz. If it's a palindrome, than a =z , b=y, c = x. So we have a string abccba. So we have a pair of each elements. Which means if the len of the string is even => there is at least one pair of each element hence the count of each element should be even. But if the len of the string is odd it means in the middle of the string there should be one and only one unpaired element. So, the count of ONLY one element should be odd.

## Game of Thrones - I

You are viewing a single comment's thread. Return to all comments →

aaabbb is not a palindrome, as aaabbb != bbbaaa. :) Let me explain the approach a bit further. Let's say we have a string abcxyz. If it's a palindrome, than a =z , b=y, c = x. So we have a string abccba. So we have a pair of each elements. Which means if the len of the string is even => there is at least one pair of each element hence the count of each element should be even. But if the len of the string is odd it means in the middle of the string there should be one and only one unpaired element. So, the count of ONLY one element should be odd.

thnkuuu ur explaination is really helpful... :)

Then why is my testcases failing here? Does the execution has problem?

abbabba bbaaabb and so on........