Given a string you have to count the total number of palindromic subsequences in the giving string and print the value
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
f(a,b)=f(a+1,b)+f(a,b-1)+1
f(a,b)=f(a+1,b)+f(a,b-1)-f(a+1,b-1)
For, str = abbaa
From the above, it is understandable that one function is called repeatedly so for the large input the repetition will be very high. Because of this problem we are using a Dynamic programming approach to avoid repetition. We are using the memorization process to solve the problem.
Problem solution:
Recursive algorithm:
DP conversion:
C++ Implementation:
Output