Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

String is Palindromable if any one combination is palindrome.

+1 vote
asked Jan 25, 2020 by anonymous

Let's say you are given a string. You can get many strings (combination) out of the given original string if you rearrange characters of original string.

String is Palindromable if any one combination is palindrome.

Example 1:

Original String: NINIT

Combinations: NINIT, NNIIT,IINNT,ININT,IITNN,NITIN,INTIN,INTNI,NTNII,NNTII and so on

Original string is  Palindromable because two palindrome can be made out of it.

Example 2:

Original String: NINNIT

Combinations: NINITN, NNINIT,IINNNT,INNINT,INITNN,NNITIN,INTNIN,INTNIN,NTNINI,NNTINI and so on

Original string is NOT Palindromable because NO palindrome can be made out of it.

Question:

Write a program to check it given string is Palindromable or not. (please note this is not a question to check if string is palindrome or not).

Complexity of the program should be less then O(n) what is using no or one loop 

1 Answer

0 votes
answered Feb 14, 2020 by anonymous 1 flag
to be palindromable, check the string size.

if even number -palindromable if each letter in the string has an even number of duplicates

if odd - palindromable if each letter in the string has an even number of duplicates and one is odd.

you can use one loop method to check number of duplicates which you can call for both even and odd options.

haven't the time to write the code... but this is a head start.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...