Given a string str, the task is to check if it can be rearranged to get a special palindromic string. If we can make it print YES else print NO.
A string is called special Palindrome that contains an uppercase and a lower case character of the same character in the palindrome position. Example- ABCcba is a special palindrome but ABCCBA is not a special palindrome.
Input: str = "ABCcba" Output: YES Input: str = "ABCCBA" Output: NO
Approach: Check if the occurrence of the uppercase letter of a character is same as the occurrence of lower case letter of the same character. And also there should be only one odd occurring character. We increase the frequency of each uppercase character by 1 and decrease the frequency of each lower case character by 1. After this, there should be either zero, 1 or -1 in the frequency array If anything else occurs then we directly say NO else print YES.
Below is the implementation of the above approach:
- 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
- Check if the characters in a string form a Palindrome in O(1) extra space
- Find the count of sub-strings whose characters can be rearranged to form the given word
- Check if any anagram of a string is palindrome or not
- Check if it is possible to create a palindrome string from given N
- Check if a string is palindrome in C using pointers
- C Program to Check if a Given String is Palindrome
- Check if a given string is a rotation of a palindrome
- Minimum length of the sub-string whose characters can be used to form a palindrome of length K
- Recursive function to check if a string is palindrome
- Python program to check if a string is palindrome or not
- Java program to check whether a string is a Palindrome
- Check if there exists any sub-sequence in a string which is not palindrome
- Given two strings check which string makes a palindrome first
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.