Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question:- Lira and her best friend are now ending highschool and soon they both will head separate ways... Lira will obviously study Computer Science while

Question:-

Lira and her best friend are now ending highschool and soon they both will head separate ways...

Lira will obviously study Computer Science while her best friend will study Arts. However, as Lira didn't want to lose contact with her, she decided to mix Art and Computer Science one last time and amaze her friend with Computer Science, so she could have a geek coding partner. To amaze her, she encoded a message in two strings, which she presented to her friend:

Lira: "So, Mary, as you can see, we have two strings here, yes? We have a first longer string, S1, which encodes our common path together, and is represented by some letters which represent our lives so far as well all the events we lived together.

The second string, S2, will be as long as the first one, or possibly shorter and it is here to represent what the future might bring to both of us.It is also only composed of letters, which represent some life events we might still experience together in the future. What I would like you to do, is to find out if the future will be just like now, and, for that, you need to find a contiguous sequence of letters in both of these two strings.

Obviously, as I want our friendship to last very, very much, I ask you to find the longest sequence of life events we might still experience together and tell me which sequence is it and how long is it :D

However, if fate doesn't want us to be together, simply tell me the number 0 and we shall both head separate ways forever.

Turns out, that after Mary solved the problem, she became so interested in CS herself, that both she and Lira are now working together at a very reputable software company. 

Input:

The input will consist of two strings composed only of the letters a..z, both of which are at most 250.000 characters in length.

Output:

The output should be as stated.

If there is a common life event in Mary and Lira's lives, you should output it on a single line and, on another line, you should output the length of the event.

Otherwise, simply output 0.

On the case where there are multiple answers, the first common event to be found on the second string, should be written to output, followed by its length.

For example:

TestInputResult
1adsyufsfdsfdsf fdyusgfdfyufd 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

The detailed answer for the above question is provided below Pyt... 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

Recommended Textbook for

More Books

Students also viewed these Computer Engineering questions

Question

How are managing quality and managing time related?

Answered: 1 week ago

Question

Is JIT possible without high-quality processes? Explain.

Answered: 1 week ago