my c++


  • 0
    L
    class Solution {
    public:
        char findTheDifference(string s, string t) {
            int temp[26]={0};
            for(int i = 0 ;i < s.size();++i){
                temp[s[i]-'a']++;
                temp[t[i]-'a']--;
            }
            temp[t[s.size()]-'a']--;
            for(int i = 0 ; i < 26;++i){
                if(temp[i] != 0)
                    return 'a'+i;
            }
        }
    };
    

Log in to reply
 

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