You are given two strings s and t. String t is generated by randomly shuffling string s and then adding one more letter at a random position. Return the letter that was added to t.
You are given two strings s and t. String t is generated by randomly shuffling string s and then adding one more letter at a random position. Return the letter that was added to t.
Example 1:
Input: {"s":"abcd","t":"abcde"}
Output: e
Constraints:
0≤s.length≤1000
t.length=s.length+1
s and t consist of lowercase English letters.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"s":"abcd","t":"abcde"}
t is s shuffled with one extra letter. Start with x = 0 and XOR in every character code of s and then of t. Pairs cancel because c ^ c = 0.
s (4)
a
b
c
d
t (5)
a
b
c
d
e
Accumulator x (low 8 bits)
x
0
0
0
0
0
0
0
0
0
letters seen an odd number of times (x is their XOR)