389. Find the Difference

一开始没看见shuffle...觉得同时遍历不就完事了。。

和那个所有数字出现2,有一个出现3次还是什么的一样,CHAR可以完美和INT相互切换。

public class Solution 
{
    public char findTheDifference(String s, String t) 
    {
        
        
        int res = 0;
        
        for(int i = 0; i < s.length();i++)
        {
            res ^= s.charAt(i);
        }
        for(int i = 0; i < t.length();i++)
        {
            res ^= t.charAt(i);
        }
      
        
        return (char)res;
    }
}
posted @ 2016-09-27 12:05  哇呀呀..生气啦~  阅读(139)  评论(0编辑  收藏  举报