← Back to challenges

Find the Difference

JavaScriptHardalgorithmsstrings

Instructions

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.

Examples

findTheDifference("", "e") ➞ "t"

findTheDifference("abcd", "abcde") ➞ "e"

findTheDifference("rt", "rst") ➞ "s"

findTheDifference("gjklmn", "ghjklmn"") ➞ "h"

findTheDifference("ae", "aea") ➞ "a"

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.