Very easy understanding C++ code


  • 0
    X

    '''
    class Solution {
    public:
    bool isAnagram(string s, string t) {
    int n1 = s.size();
    int n2 = t.size();
    vector<int> a(n1);
    vector<int> b(n2);
    for(int i = 0;i<n1;++i)
    {
    a[i] = int(s[i]);
    }
    for(int j = 0;j<n2;++j)
    {
    b[j] = int(t[j]);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if(a == b)
    return true;
    else
    return false;

    }
    

    };
    '''


Log in to reply
 

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