【leetcode389】389. Find the Difference

异或 找不同 —。—

 1 public class Solution {
 2     public char findTheDifference(String s, String t) {
 3         char temp = 0x00;
 4         for(int i = 0;i < s.length();i++){
 5             temp =(char) (temp ^ s.charAt(i));
 6         }
 7         for(int i = 0;i < t.length();i++){
 8             temp =(char) (temp ^ t.charAt(i));
 9         }
10         return temp;
11     }
12 }

 

posted @ 2017-04-13 23:42  Yaaaaa  阅读(170)  评论(0)    收藏  举报