Find the Difference

Given two strings s and t, where t is generated by shuffling s and adding one extra letter, return the extra letter. Pattern focus: XOR Trick. XOR character codes to cancel matched characters and reveal the extra one.

Input Format

s = original string, t = shuffled string with one extra character

Output Format

the extra character

Constraints

  • 1 <= input size <= 10^5
  • -10^9 <= numeric values <= 10^9
  • s, t must satisfy the format described in inputFormat.

Examples

Example 1:

Input:

s = "abcd"
t = "abcde"

Output:

e

Explanation:

Only 'e' appears in t and not in s.

Example 2:

Input:

s = ""
t = "y"

Output:

y

Explanation:

The added character is the whole result.

Loading...
Find the Difference - Bit Manipulation