C# Solution


  • 0
        public bool IsAnagram(string s, string t) {
            if (s.Length != t.Length)
                return false;
            
            char[] source = s.ToCharArray(), target = t.ToCharArray();
            
            Array.Sort(source);
            Array.Sort(target);
            
            for (int i = 0; i <= source.Length - 1; i++)
                if(source[i] != target[i])
                    return false;
            
            return true;
        }

Log in to reply
 

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