Given a string, convert the string to palindrome without any modifications like adding a character, removing a character, replacing a character etc.
Input : "mdaam" Output : "madam" or "amdma" Input : "abb" Output : "bab" Input : "geeksforgeeks" Output : "No Palindrome"
1. Count occurrences of all characters.
2. Count odd occurrences. If this count is greater than 1 or is equal to 1 and length of the string is even then obviously palindrome cannot be formed from the given string.
3. Initialize two empty strings firstHalf and secondHalf.
4. Traverse the map. For every character with count as count, attach count/2 characters to end of firstHalf and beginning of secondHalf.
5. Finally return the result by appending firstHalf and secondHalf
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 characters of a given string can be rearranged to form a palindrome
- Check if the characters in a string form a Palindrome in O(1) extra space
- Minimum length of the sub-string whose characters can be used to form a palindrome of length K
- Rearrange the characters of the string such that no two adjacent characters are consecutive English alphabets
- Rearrange a string so that all same characters become d distance away
- Rearrange characters in a string such that no two adjacent are same
- Rearrange characters in a string such that no two adjacent are same using hashing
- Rearrange a string so that all same characters become atleast d distance away
- Rearrange a string in the form of integer sum followed by the minimized character
- Next word that does not contain a palindrome and has characters from first k
- Minimum insertions to form a palindrome | DP-28
- Find if string is K-Palindrome or not using all characters exactly once
- Minimum insertions to form shortest palindrome
- Minimum insertions to form a palindrome with permutations allowed
- Check if a string can be rearranged to form special palindrome
- Maximum length palindrome that can be created with characters in range L and R
- Check if a doubly linked list of characters is palindrome or not
- Print the arranged positions of characters to make palindrome
- Find the player who rearranges the characters to get a palindrome string first
- Count pair of strings whose concatenation of substrings form a palindrome