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 if a string is palindrome in C using pointers
- Check if it is possible to create a palindrome string from given N
- 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 a string is palindrome or not
- Given two strings check which string makes a palindrome first
- Check if characters of a given string can be rearranged to form a palindrome
- Check if string can be rearranged so that every Odd length Substring is Palindrome
- Python program to check if given string is vowel Palindrome
- Check if a string can be rearranged to form special palindrome
- TCP Client-Server Program to Check if a Given String is Palindrome
- Check if the characters in a string form a Palindrome in O(1) extra space
Improved By : vt_m