1321. Find the Difference Between Two Strings (XOR)

EasyBit ManipulationBit ManipulationXORString

String t is formed by shuffling string s and then adding one extra lowercase letter at a random position. Return that extra letter. XOR of all character codes cancels the shared letters and leaves the added one.

Input: A JSON object {"s": <string>, "t": <string>} where t is s shuffled plus one extra character.

Output: Return the single extra character as a string.

Examples

Example 1
Input: {"s":"abcd","t":"abcde"}
Output: e
Explanation: All shared letters cancel, leaving 'e'.
Example 2
Input: {"s":"","t":"z"}
Output: z
Explanation: With empty s the extra letter is 'z'.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →