Given a string str, the task is to count the number of ways a palindromic sub-string could be formed by concatenation of three sub-strings x, y and z of the string str such that all of them are non-overlapping i.e. sub-string y occurs after sub-string x and sub-string z occurs after sub-string y.
Input: str = “abca”
The two valid pairs are (“a”, “b”, “a”) and (“a”, “c”, “a”)
Input: str = “abba”
Approach: Find all the possible pairs of three non-overlapping sub-strings and for every pairs check whether the string generated by their concatenation is a palindrome or not. If yes then increment the count.
Below is the implementation of the above approach:
- Lexicographical concatenation of all substrings of a string
- Check if a linked list of strings forms a palindrome
- Minimum steps to delete a string after repeated deletion of palindrome substrings
- Count all palindrome which is square of a palindrome
- Count substrings that contain all vowels | SET 2
- Count all substrings having character K
- Count substrings with same first and last characters
- Count of substrings of a binary string containing K ones
- Count Substrings with equal number of 0s, 1s and 2s
- Count of total anagram substrings
- Count of substrings which contains a given character K times
- Number of substrings with count of each character as k
- Recursive solution to count substrings with same first and last characters
- Count number of distinct substrings of a given length
- Count number of substrings with numeric value greater than X
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.