Solution in C++


  • 0

    class Solution {
    public:
    bool fin;
    char ch=0;
    unordered_map<char, int> vect;
    bool isAnagram(string s, string t) {
    if(s==t) return true;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    int max1=max(s.length(),t.length());
    for(int i=0;i<max1;i++)
    {
    if(s[i]!=t[i])
    {
    fin= false; return fin;
    }else{
    fin=true;
    }
    }return fin;

    }
    

    };


Log in to reply
 

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