## New coder, Step further

winter is coming...

# 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.

    char findTheDifference(string s, string t) {
int count1[26] = {0};
int count2[26] = {0};
int i;
for (i = 0; i < s.size(); i++) {
count1[s[i]-'a']++;
}
for (i = 0; i < t.size(); i++) {
count2[t[i]-'a']++;
}
for (i = 0; i < 26; i++) {
if (count1[i] != count2[i]) return 'a'+i;
}
return NULL;
}

#### [leetcode] 389. Find the Difference 解题报告

2016-08-29 14:10:50

#### leetcode算法——389. Find the Difference(基于JAVA)

2016-09-06 11:48:56

#### leetcode_389 Find the Difference

2016-08-29 20:37:18

#### 389. Find the Difference。

2018-02-25 19:45:27

#### [leetcode]389. Find the Difference

2018-06-20 17:47:41

#### Leetcode 389. Find the Difference

2016-09-02 11:24:55

#### Problem 389. Find the Difference

2017-03-20 12:43:10

#### [leetcode]--389. Find the Difference

2017-02-02 12:25:22

#### [LeetCode]--389. Find the Difference

2016-10-17 11:32:07

#### leetcode - 389. Find the Difference

2018-02-28 22:16:11