Beispiel #1
0
        public static bool IsAnagram(string s, string t)
        {
            if (s.Length != t.Length)
            {
                return(false);
            }

            var alphabets = new short[26];

            for (var i = 0; i < s.Length; i++)
            {
                alphabets[s[i] - 'a']++;
                alphabets[t[i] - 'a']--;
            }

            return(!alphabets.Any(alphabet => alphabet > 0));
        }