A trail-mix vendor describes a batch as a string of lowercase letters, where each letter names one scoop of a single ingredient. To prepare a restock, the vendor takes every scoop from the original batch, shuffles their order however they like, and then mixes in exactly one additional scoop of some ingredient (which may or may not be an ingredient already in the batch).
Given the original batch string s and the restocked batch string t, where t is some shuffling of s plus exactly one extra character, determine which ingredient letter was the extra one mixed in.
Line 1: the string s (may be empty). Line 2: the string t, whose length is exactly one more than the length of s.
A single line containing the one extra lowercase letter that appears in t but was not part of the original batch s.
Example 1
Input
abcd abcde
Expected
e
Explanation
t = "abcde" contains every letter of s = "abcd" plus one extra letter, 'e', which was mixed in. Output "e".
Example 2
Input
y
Expected
y
Explanation
s is empty, so the entire restocked batch t = "y" is the one extra ingredient. Output "y".
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →