Skip to content

Instantly share code, notes, and snippets.

@Roger7410
Created October 13, 2016 22:38
Show Gist options
  • Select an option

  • Save Roger7410/b7e5dd03c9669017c8382bc6fe72826f to your computer and use it in GitHub Desktop.

Select an option

Save Roger7410/b7e5dd03c9669017c8382bc6fe72826f to your computer and use it in GitHub Desktop.
//It is a more effictive way than HASHTABLE
public class Solution {
public char findTheDifference(String s, String t) {
char[] ss = s.toCharArray();
char[] tt = t.toCharArray();
char result = 0;
for(int i = 0; i <ss.length; i++){
result ^= ss[i];
result ^= tt[i];
}
result ^= tt[tt.length-1];
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment