Computer Science, asked by branshem8978, 18 days ago

Given a string S, find the number of substrings A such that there is always a prefix substring B, such that concatenation of either of them with the reverse of the other, results in a palindrome.

Answers

Answered by venom0136
0

Answer:

Count special palindromes in a String

Count special palindromes in a StringGiven a String s, count all special palindromic substrings of size greater than 1. A Substring is called special palindromic substring if all the characters in the substring are same or only the middle character is different for odd length. Example “aabaa” and “aaa” are special palindromic substrings and “abcba” is not special palindromic substring.

Examples :

Input : str = " abab"

Input : str = " abab"Output : 2

Input : str = " abab"Output : 2All Special Palindromic substring are: "aba", "bab"

Input : str = " abab"Output : 2All Special Palindromic substring are: "aba", "bab"Input : str = "aabbb"

Input : str = " abab"Output : 2All Special Palindromic substring are: "aba", "bab"Input : str = "aabbb"Output : 4

Input : str = " abab"Output : 2All Special Palindromic substring are: "aba", "bab"Input : str = "aabbb"Output : 4All Special substring are: "aa", "bb", "bbb", "bb"

Simple Solution is that we simply generate all substrings one-by-one and count how many substring are Special Palindromic substring. This solution takes O(n3) time.

Simple Solution is that we simply generate all substrings one-by-one and count how many substring are Special Palindromic substring. This solution takes O(n3) time.Efficient Solution

Simple Solution is that we simply generate all substrings one-by-one and count how many substring are Special Palindromic substring. This solution takes O(n3) time.Efficient Solution There are 2 Cases :

Simple Solution is that we simply generate all substrings one-by-one and count how many substring are Special Palindromic substring. This solution takes O(n3) time.Efficient Solution There are 2 Cases : Case 1: All Palindromic substrings have same character :

Simple Solution is that we simply generate all substrings one-by-one and count how many substring are Special Palindromic substring. This solution takes O(n3) time.Efficient Solution There are 2 Cases : Case 1: All Palindromic substrings have same character : We can handle this case by simply counting the same continuous character and using formula K*(K+1)/2 (total number of substring possible : Here K is count of Continuous same char).

please Mark Me Brain list Answer

Answered by udaykiran0451
0

Answer:

5

Explanation:

a,ab,abc,abcd,abcde

Similar questions