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 with same first and last characters
- Count all substrings having character K
- Count substrings that contain all vowels | SET 2
- Count of substrings of a binary string containing K ones
- Count of substrings which contains a given character K times
- Count Substrings with equal number of 0s, 1s and 2s
- Number of substrings with count of each character as k
- Count of total anagram substrings
- Count distinct substrings that contain some characters at most k times
- Recursive solution to count substrings with same first and last characters
- Count number of distinct substrings of a given length
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.