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.
- Check if it is possible to create a palindrome string from given N
- Check if a string is palindrome in C using pointers
- Check if a given string is a rotation of a palindrome
- C Program to Check if a Given String is Palindrome
- Recursive function to check if a string is palindrome
- Python program to check if a string is palindrome or not
- Check if there exists any sub-sequence in a string which is not palindrome
- Given two strings check which string makes a palindrome first
- Check if characters of a given string can be rearranged to form 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 the characters in a string form a Palindrome in O(1) extra space
- Covert string X to an anagram of string Y with minimum replacements
- Number of sub-strings which are anagram of any sub-string of another string
- Check whether two strings are anagram of each other
Improved By : vt_m