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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check if a given string is Even-Odd Palindrome or not
- Check given string is oddly palindrome or not
- C Program to Check if a Given String is Palindrome
- Check given string is oddly palindrome or not | Set 2
- Check whether the given string is Palindrome using Stack
- 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 both halves of a string are Palindrome or not
- Given two strings check which string makes a palindrome first
- 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
- 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 characters of a given string can be rearranged to form a palindrome
- Check if string is palindrome after removing all consecutive duplicates
- 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
Improved By : vt_m