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.
- Rearrange the characters of the string such that no two adjacent characters are consecutive English alphabets
- 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
- Longest substring whose characters can be rearranged to form a Palindrome
- Rearrange a string in the form of integer sum followed by the minimized character
- Rearrange a string so that all same characters become d distance away
- Rearrange a string so that all same characters become atleast 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 string such that no pair of adjacent characters are of the same type
- Check if it is possible to rearrange a binary string with alternate 0s and 1s
- Sentence Palindrome (Palindrome after removing spaces, dots, .. etc)
- Count all palindrome which is square of a palindrome
- Minimum insertions to form a palindrome | DP-28
- 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
- Find index i such that prefix of S1 and suffix of S2 till i form a palindrome when concatenated
- Count pair of strings whose concatenation of substrings form a palindrome