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

public class Solution {
public char findTheDifference(String s, String t) {
int[] counts=new int[26];
int[] countt=new int[26];
for (int i=0;i<s.length();i++){
counts[s.charAt(i)-'a']++;
}
for (int i=0;i<t.length();i++){
countt[t.charAt(i)-'a']++;
}
for (int j=0;j<26;j++){
if (counts[j]!=countt[j]){
return (char) (j+'a');
}
}
return ' ';
}
}

#### leetcode 389 Find the Difference C++

2016-08-31 19:56:18

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

2016-08-29 14:10:50

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

2016-09-06 11:48:56

#### 389. Find the Difference的C++解法

2017-03-31 11:05:13

#### 【python】【leetcode】【算法题目389—Find the Difference】

2016-12-04 12:03:33

#### leetcode_389 Find the Difference

2016-08-29 20:37:18

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

2016-10-17 11:32:07

#### Problem 389. Find the Difference

2017-03-20 12:43:10

#### Leetcode 389. Find the Difference

2016-09-02 11:24:55

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

2017-02-02 12:25:22