Loading content...
You are given two strings: an original string and a modified string.
The modified string is created by taking the original string, randomly rearranging its characters (shuffling), and then inserting exactly one additional character at some random position.
Your task is to identify and return the extra character that was added to create the modified string.
Key Observations:
modified string will always have exactly one more character than the original string.original are present in modified (possibly reordered).original.s = "abcd"
t = "abcde""e"The original string 'abcd' was shuffled (in this case, order is unchanged) and the character 'e' was inserted at the end. Since 'e' was not in the original string, it's the extra character.
s = ""
t = "y""y"The original string is empty. The modified string contains only 'y', which means 'y' is the character that was added.
s = "hello"
t = "lloehx""x"The original string 'hello' was shuffled to 'lloeh', and then 'x' was inserted. The character 'x' was not present in 'hello', making it the extra character.
Constraints