easy understand Java solution


  • 0
    D
    public char findTheDifference(String s, String t) {
        char [] a=s.toCharArray();
    	char [] b=t.toCharArray();
    	int sum1=0;
    	int sum2=0;
    	for(int i=0;i<a.length;i++){
            sum1+=a[i]-'a';	
    	}
    
    	for(int i=0; i<b.length;i++){
            sum2+=b[i]-'a';
    	}
    
    	return (char) ('a'+(sum2-sum1));
    }

Log in to reply
 

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