i loop through an alphabetically sorted t. if a letter in t is an extra as compared to alphabetically sorted s i return the alphabet.
-
Time complexity: O(Nlogn)
-
Space complexity:O(N)
function findTheDifference(s: string, t: string): string {
let ss = s.split("").sort()
let ts = t.split("").sort()
for (let i = 0; i < ts.length; i++) {
if (ts[i] !== ss[i]) {
return ts[i]
}
}
};