You are not logged in. Please login at to post your questions!


PERMPAL Unofficial Editorial

Hello Community! I wanted to contribute to the community but since I don't have enough karma points, I want you to upvote only if you like my unofficial editorial on PERMPAL:

My approach:

  1. The answer will be -1 only when the count of any of 26 characters is odd and there exists more than one such character's example : abbc, here we can see both 'a' and 'c' have odd count in the given string.
  2. In any other case, we will always find a answer, that is palindrome.
  3. Based on above point, we will deal with two cases :
    (A)When only one character comes with odd count and rest other characters with even count.
    (B)When all the character in the given string are of even count.

Now the question comes How to solve this?

So it is much clear for case 3(A) that the odd count characters should be in the middle of string in order to make it palindrome, eg abbba n(b)=3 i.e odd

Since the ordering of characters won't matter in case of even count, we will print index one by one from vector<vector<int>> v(26), which I have used this for storing the index of each character(a-z) in the string. In the output I need to just print the even count characters index ,simultaneously from beginning and end. Keep in mind that the odd count character should be in the middle.

If you give up, you can see my solution here.

All suggestions are welcome!

Thanks Community, Happy Coding!

asked 13 Feb, 12:25

ayushgupta1997's gravatar image

accept rate: 0%

edited 15 Feb, 19:45

taran_1407's gravatar image


I have updated the formatting of certain things. Hope you didn't mind.

Btw, Nice Editorial.

(15 Feb, 19:47) taran_14076★

Thanks a lot @taran_1407 :)

(16 Feb, 17:44) ayushgupta19974★

Hello friends....I'm quite stuck on this solution since yesterday..I'm a newbie and tried to solve this question...however it's giving me WA..can you please tell me where I'm wrong in my code? link to code

Thanks in advance!!


answered 15 Feb, 19:31

tra_dax's gravatar image

accept rate: 0%

This is your ac solution:

U were trying to insert at position which didnt existed,(U may google about this as i dont often code with python)

(15 Feb, 19:55) vivek_19982996★

@vivek_1998299 thank you so saved my day!!

(16 Feb, 18:21) tra_dax1★ Please can some one tell me what is wrong with my code??


answered 17 Feb, 01:19

veda_19's gravatar image

accept rate: 0%

@veda_19 Hi ! You can check out my solution
I've used Hashing and fast IO. The logic is to get a new string and obtain its mid-point. Then add to the left and right of that mid-point the alphabets that occur even. For odd alphabets simply put them in between the new String.

Hope I helped You !

Happy Coding :)


answered 17 Feb, 02:04

dewanshnigam's gravatar image

accept rate: 0%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 13 Feb, 12:25

question was seen: 481 times

last updated: 17 Feb, 04:26