We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d5017db commit 17db9b2Copy full SHA for 17db9b2
Contest/src/_20160827_2nd_contest/FindTheDifference.java
@@ -0,0 +1,20 @@
1
+package _20160827_2nd_contest;
2
+
3
+public class FindTheDifference {
4
+ public char findTheDifference(String s, String t) {
5
+ int[] counts = new int[128];
6
+ char[] schars = s.toCharArray();
7
+ char[] tchars = t.toCharArray();
8
+ for(int i = 0; i < schars.length; i++){
9
+ counts[schars[i]]++;
10
+ }
11
+ for(int i = 0; i < tchars.length; i++){
12
+ counts[tchars[i]]--;
13
14
+ char result = 'a';
15
+ for(int i = 0; i < 128; i++){
16
+ if(counts[i] != 0) result = (char) i;
17
18
+ return result;
19
20
+}
0 commit comments