Valid Anagram simple c++ solution


  • 0
    P
    class Solution {
    public:
        bool isAnagram(string s, string t) {
            
            if(s.size() != t.size())
            {
                return false;
            }
            else
            {
                sort(s.begin(), s.end());
                sort(t.begin(), t.end());
                return s == t;
            }
        }
    };

Log in to reply
 

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