As per WIKI An anagram is direct word switch or word play, the result of rearranging the letters of a word or phrase to produce a new word or phrase,        using all the original letters exactly once; for example, the word anagram can be rearranged into nag a ram.What is the Best solution in C# in terms of O(n)? I have below code which works fine with test casesDebit card, Bad credit, Dormitory, Dirty Room The earthquakes, The queer shakepublic static bool IsAnagram(string input, string anagram)    {        //corner cases        if (string.IsNullOrEmpty(input) || string.IsNullOrEmpty(anagram))        {            return false;        }        if (input == anagram)        {            return false;        }        var charMap = new Dictionary<char, int>();        for (int i = 0; i < input.Length; i++)        {            if (!char.IsLetterOrDigit(input[i])) { continue; }            if (charMap.ContainsKey(char.ToLowerInvariant(input[i])))            {                charMap[char.ToLowerInvariant(input[i])]++;            }            else            {                charMap.Add(char.ToLowerInvariant(input[i]), 1);            }        }        for (int i = 0; i < anagram.Length; i++)        {            if (!char.IsLetterOrDigit(anagram[i])) { continue; }            if (!charMap.ContainsKey(char.ToLowerInvariant(anagram[i])))            {                return false;            }            if (--charMap[char.ToLowerInvariant(anagram[i])] < 0)            {                return false;            }        }        return true;    }
Anagram in C# Solution
c#;strings