Question: You have two strings, a and b . Find a string, s . such that: s can be expressed as s = s 8 +

You have two strings, a and b. Find a string, s. such that:
s can be expressed as s=s8+sb where s4 is a non-emply substring of a and s6 is a non-empty rubstring of b.
s is a palindromic string.
The length of s is as long as possible.
For each of the q pairs of strings ia7 and (:bi} received as input, find and print string sq on a new line. If you'se able to form more than one valid string s., print whichever one comes first alphabetically. if there is no waid answer, print -1 instead.
Input Format
The first line convains a tingle integer, of denoting the number of quenes the subsequent fines descrite each query over two lines:
The first fine contains a sogle string denating a.
The secono fine contains a single string denoung b.
Constraims
1210
*1lan18-103
 You have two strings, a and b. Find a string, s.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!