java so easy solution 11ms


  • 0
    J
    public static char findTheDifference(String s, String t) {
    		char[] ct = t.toCharArray();
            char[] cs = s.toCharArray();
            Arrays.sort(ct);
            Arrays.sort(cs);
            for(int i=0;i<cs.length;i++){
            	if(cs[i]!=ct[i]){
            		return ct[i];
            	}
            }
            return ct[ct.length-1];
    		
    	}
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.