Easy Java Solution Using ASCII


  • 0
    S

    '''
    public char findTheDifference(String s, String t) {

        int sum = 0 ;
    
        for(int i = 0 ; i<s.length();i++){
            sum = sum + s.charAt(i);
        }
        
        for(int i = 0 ; i<t.length();i++){
            sum = sum - t.charAt(i);
        }
        
        sum = Math.abs(sum);
        
        return (char) sum;
    }
    

    }


Log in to reply
 

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