Given two stringssandtwhich consist of only lowercase letters.
Stringtis generated by random shuffling stringsand then add one more letter at a random position.
Find the letter that was added int.
Example:
Input:
s = "abcd"
t = "abcde"
Output:
e
Explanation:
'e' is the letter that was added.
Subscribeto see which companies asked this question.
Hide Tags
Hide Similar Problems
public class Solution {
public char findTheDifference(String s, String t) {
int result = 0;
for(char c : s.toCharArray()){
result ^= c;
}
for(char c : t.toCharArray()){
result ^= c;
}
return (char)result;
}
}