Help in Weird Palindrome Making Long Challenge November

Please help me understand what is wrong with my code, and what is the logic to solve this problem…
The Question Asked in November Long Challenge
MY SOLUTION

1 Like

You can refer the editorial.

1 Like

So I went through your code, and I was confused with the approach. The approach could have been like this.

  1. Take the sum of the entire array. if the sum is odd that means it is an odd length string and if the sum is even then it is an even length string.
  2. Count the number of odd character string.
  3. Two different odd characters should be paired up. aaa and bbb should be converted to even aaaaaa now it will be useful for making pallindrome
  4. If the string length is odd then the odd character after pair up should be 1 because there needs to be a odd character in the middle of the string FOR EG acbca
  5. If the string length is even then the odd character after pair up should be 0 because there needs to be 0 characters in the middle of the string FOR EG acca
2 Likes

Really appreciate your answer! I think that I did not really get the logic, so messed up the code too…
Thanks for your reply! :slight_smile:

1 Like