Given a palindrome String, the task is to find the maximum length of the double string and its length that can be obtained from the given palindromic string. A double string is a string that has two clear repetition of a substring one after the other.
Input: abba Output: abab 4 Explanation: abab is double string which can be obtained by changing the order of letters Input: abcba Output: abab 4 Explanation: abab is double string which can be obtained by changing the order of letters and deleting letter c
Approach: The double string can be considered in two cases:
- Case 1: If the length of the string is even then the length of double string will always be the length of string.
- Case 2: If the length of the string is odd then the length of double string will always be the length of string – 1.
Below is the implementation of the above approach
abab 4 abcdabcd 8
Time Complexity: O(1).
- Find longest palindrome formed by removing or shuffling chars from string
- Double Base Palindrome
- Longest Possible Chunked Palindrome
- Length of the longest substring that do not contain any palindrome
- Longest palindrome subsequence with O(n) space
- Print longest palindrome word in a sentence
- Convert the string into palindrome string by changing only one character.
- Find the longest sub-string which is prefix, suffix and also present inside the string
- Find the longest sub-string which is prefix, suffix and also present inside the string | Set 2
- Find length of longest subsequence of one string which is substring of another string
- Print the longest prefix of the given string which is also the suffix of the same string
- Longest sub string of 0's in a binary string which is repeated K times
- Longest string in an array which matches with prefix of the given string
- Length of longest palindrome list in a linked list using O(1) extra space
- Check whether the given string is Palindrome using Stack
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.