leetcode 389. Find the Difference
Given two strings s and t which consist of only lowercase letters.
String t is generated by random shuffling string s and then add one more letter at a random position.
Find the letter that was added in t.
Example:
Input:
s = "abcd"
t = "abcde"
Output:
e
Explanation:
'e' is the letter that was added.
AC:
char findTheDifference(char* s, char* t) { int len1=strlen(s); int len2=strlen(t); int num=0; char c; for(int i=0;i<len1;i++) { num+=t[i]-s[i]; } for(int i=len1;i<len2;i++) { num+=t[i]; } c=num; return c; }