dsa · easy
Find the Difference
t is a shuffled copy of s with one extra character inserted somewhere. Return that extra character.
Example
s = "cat", t = "tact": both share c, a, t. After matching those, t still has one leftover t → "t".
s = "", t = "z": s is empty, so the whole of t is the extra letter → "z".
s = "ae", t = "aea": the extra letter is "a".
## Arguments - s — original string (may be empty) - t — s shuffled, plus exactly one extra lowercase letter
Constraints
0 <= s.length <= 1000 t.length == s.length + 1 s and t contain lowercase English letters Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.
Examples
Example 1
Input: "cat" "tact" Expected: t
Example 2
Input: "" "z" Expected: z
Example 3
Input: "ae" "aea" Expected: a