Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions