Skip to content

Commit

Permalink
LeetCode389.找不同
Browse files Browse the repository at this point in the history
  • Loading branch information
yangxuechen committed Jun 30, 2018
1 parent 2501f69 commit 952ab57
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions LeetCode1/LeetCode389.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package leetCode;

public class LeetCode389 {

public static void main(String[] args) {
// TODO Auto-generated method stub
char c=findTheDifference("asdf","asdfe");
System.out.println(c);
}
public static char findTheDifference(String s, String t) {
int[] ch=new int[26];
for(char c:s.toCharArray()) {
ch[c-'a']++;
}
for(char c:t.toCharArray()) {
ch[c-'a']--;
}
int i;
for( i=0;i<26;i++) {
if(ch[i]!=0) {
break;
}
}
char c='a';
for(int j=0;j<i;j++) {
c++;
}
return c;
}

}

0 comments on commit 952ab57

Please sign in to comment.