c++ solution


  • 0
    A
    class Solution {
    public:
        char findTheDifference(string s, string t) {
            int size_s = s.length();
            int size_t = t.length();
    
            for(int i=0; i<size_s; i++){
                int loc = t.find(s.at(i));
                t.erase(loc,1);
            }
            if(t.length() == 1){
                return t.at(0);
            } else {
                return '\0';
            }
        }
    };
    

Log in to reply
 

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