Find the Difference

EasyStringSorting

Description

You are given two strings s and t. String t is generated by random shuffling string s and adding one extra letter at a random position. Return the letter that was added to t.

Examples

Input:s = "abcd", t = "abcde"
Output:"e"
Explanation:

Comparing character counts: s='abcd' has a,b,c,d each once. t='abcde' has an extra 'e', which is the added letter.

Input:s = "", t = "y"
Output:"y"
Explanation:

String s is empty and t has one character 'y', so the added letter is 'y'.

Input:s = "xyz", t = "zyxm"
Output:"m"
Explanation:

String t is a shuffled version of string s with letter 'm' added. Even though the order is different (xyz vs zyx), the extra character 'm' can still be identified.

Constraints

  • 0 ≤ s.length ≤ 1000

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!