find-the-difference

https://leetcode.com/problems/find-the-difference/

public class Solution {
    public char findTheDifference(String s, String t) {
        char[] sch = s.toCharArray();
        char[] tch = t.toCharArray();
        Arrays.sort(sch);
        Arrays.sort(tch);
        for (int i=0; i<sch.length; i++) {
            if (sch[i] != tch[i]) {
                return tch[i];
            }
        }
        return tch[tch.length-1];
    }
}
原文地址:https://www.cnblogs.com/charlesblc/p/5822791.html