find-the-difference error

i tried using vector where i stored S and T and if we find any char which dont have an pair then we return that single one.
its fails in empty string .

class Solution {
public:
    char findTheDifference(string s, string t) 
    {/*🧼*/
        vector <char > v;
        char k;
        for(int i=0;i<s.length();i++)
            v.push_back(s[i]);
        
        for(int i=0;i<t.length();i++)
            v.push_back(t[i]);
        
        sort(v.begin(),v.end());
      
        for(int i=0;i<v.size();i++)
          {
            if(v[i] == v[i+1])
                i++;
            else
            {
             k=v[i];
             break;
            }}
        return k;
    }  
};
Comments (0)