Write a program that reads two strings s and t, each on its own line. Each string will contain only lowercase letters. The program should print a string u such that
- Some permutation of u is a subsequence of s.
- Some permutation of u is a subsequence of t.
- u is as long as possible.
A subsequence is not necessarily contiguous. If there is more than one longest possible u, print the one that comes first alphabetically.
Sample input:
watermelon
summertime
Output:
eemrt
Sample input #2:
rhinoceros
elephant
Output:
ehn
Hint: If you have an integer i in the range 0 ≤ i < 26 and you want to convert it to a letter from 'a' to 'z', you can do this:
char c = (char) ('a' + i);