172. Find the Difference (One Extra Character)

EasyStringString

You are given two strings s and t. String t is generated by randomly shuffling string s and then adding one extra lowercase letter at a random position.

Return the extra letter that was added to t.

Input: Two comma-separated strings: s and t. len(t) == len(s)+1.

Output: A single character — the extra letter added to t.

Examples

Example 1
Input: abcd,abcde
Output: e
Explanation: 'e' is the extra character added to t.
Example 2
Input: a,aa
Output: a
Explanation: An extra 'a' was added.
Example 3
Input: ae,aea
Output: a
Explanation: 'a' was added; result is one extra 'a'.

Constraints

Asked by

GoogleAccentureBloombergAmazonMicrosoftMeta
Solve this problem in the editor →