389. Find the Difference
Question
You are given two strings s and t.
The string t is generated by randomly shuffling the strings s and then adding another letter at a random location.
Return the letter that was added to t.
Example 1:
Input: s = "abcd", t = "abcde"
Output: "e"
Explanation: 'e' is the letter that was added.
Example 2:
Input: s = "", t = "y"
Output: "y"
Solution
class Solution {
public:
char findTheDifference(string s, string t) {
int a[26]={0},b[26]={0};
for(int i=0;i
Comments
Post a Comment