Question
The Lost Scrolls of Harmony

In the ancient Kingdom of Letters, two mystical scrolls — Scroll A and Scroll B — were discovered in the ruins of an old library. Each scroll holds a unique sequence of symbols.

You are given Scroll A and Scroll B in the form of two strings, text1 and text2.

Your task is to uncover the longest harmonious sequence — a string that appears in both scrolls in the same order, though not necessarily consecutively.

If no such sequence exists, return an empty string.

If there are multiple possible answers, you may return any one of them.

Input
The first line of the input contains a string representing text1.
The second line of the input contains a single string representing text2.
Output
Print the longest harmonious sequence — a string that appears in both scrolls in the same order, though not necessarily consecutively.
Example
Input:
abcde
ace
Output:
ace
Explanation:
The string "ace" is the longest subsequence that appears in both of the strings in the same order.

Online