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


class Solution {
public:
char findTheDifference(string s, string t) {
int slength=s.length();
int stable[100];
memset(stable,0,sizeof(stable));
for(int i=0; i<slength; i++)
{
stable[s[i]-'a']++;
}
char ans;
for(int i=0; i<slength+1; i++)
{
stable[t[i]-'a']--;
if(stable[t[i]-'a']<0)
{
ans=t[i];
}
}
return ans;
}
};

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

2016-09-06 11:48:56

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

2016-08-29 14:10:50

#### Leetcode-530. Minimum Absolute Difference in BST

2017-02-26 13:38:44

#### [leetcode] 530. Minimum Absolute Difference in BST

2017-03-01 16:19:38

#### LeetCode-530. Minimum Absolute Difference in BST (Java)

2017-06-18 08:51:44

#### Problem 6 Sum square difference （数学）

2016-10-26 12:49:03

#### leetcode_389 Find the Difference

2016-08-29 20:37:18

#### [LeetCode]530. Minimum Absolute Difference in BST(BST的最小绝对差)

2017-04-02 23:34:49

#### [leetcode]: 530. Minimum Absolute Difference in BST

2017-05-17 14:20:33

#### YOLO traning data

2018年04月09日 41KB 下载