Test Anagram

Run Settings
LanguageC#
Language Version
Run Command
// Entry point name must be "Solution" using System; using System.Collections.Generic; public static class Solution { private static void Main() { Console.WriteLine("Hello, world!"); if (AreStringsAnagrams("kayak", "kaaky")) { Console.WriteLine("Strings are anagrams"); } } private static bool AreStringsAnagrams(string str1, string str2) { if (str1.Length != str2.Length) return false; Dictionary<char, int> charsCount = new Dictionary<char, int>(); foreach (char singleCharacter in str1) { if (charsCount.ContainsKey(singleCharacter)) { charsCount[singleCharacter]++; } else { charsCount[singleCharacter] = 1; } } foreach (char singleCharacter in str2) { if (!charsCount.ContainsKey(singleCharacter)) { return false; } else { charsCount[singleCharacter]--; } } return true; } }
Editor Settings
Theme
Key bindings
Full width
Lines