Question: You are given a string S of length N . You are also given a string array str of size M . It is given
You are given a string S of length N You are also given a string array str of size M
It is given that a string X is beautiful if there is a subsequence concatenation K from the string array str that meets the following conditions:
The length of K is equal to the length of X
The concatenation of K and the string X is a palindrome string.
This means if str abdc X "cda" then we can take the subsequence adc from str and concatenate them to get K "adc". The length of "adc" is equal to the length of X and their concatenation is a palindrome string
Find the longest prefix length from S that can be divided into beautiful substrings.
Notes:
It is given that a string is a palindrome string if reading it from left to right is equal to reading it from right to left.
Input Format
The first line contains an integer,N denoting the length of string S
The next line contains an integer, M denoting the size of the string array str
The next line contains a string S denoting the given string.
Each line i of the M subsequent lines where i M contains a string describing stri
input: n m S"abcda", strabdc
output:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
