We have given a anagram string and we have to check whether it can be made palindrome o not.
Input : geeksforgeeks Output : No There is no palindrome anagram of given string Input : geeksgeeks Output : Yes There are palindrome anagrams of given string. For example kgeeseegk
This problem is basically same as Check if characters of a given string can be rearranged to form a palindrome. We can do it in O(n) time using a count array. Following are detailed steps.
1) Create a count array of alphabet size which is typically 256. Initialize all values of count array as 0.
2) Traverse the given string and increment count of every character.
3) Traverse the count array and if the count array has more than one odd values, return false. Otherwise return true.
This article is contributed by Rishabh Jain. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- C Program to Check if a Given String is Palindrome
- Check if a given string is a rotation of a palindrome
- Check whether the given string is Palindrome using Stack
- Check if a string is palindrome in C using pointers
- Check if it is possible to create a palindrome string from given N
- Python program to check if a string is palindrome or not
- Given two strings check which string makes a palindrome first
- Check if there exists any sub-sequence in a string which is not palindrome
- Recursive function to check if a string is palindrome
- Java program to check whether a string is a Palindrome
- Python program to check if given string is vowel Palindrome
- Check if a string can be rearranged to form special palindrome
- Check if string can be rearranged so that every Odd length Substring is Palindrome
- TCP Client-Server Program to Check if a Given String is Palindrome
- Check if characters of a given string can be rearranged to form a palindrome
Improved By : vt_m