Skip to content

Instantly share code, notes, and snippets.

@kencenerelli
Created May 1, 2013 16:17
Show Gist options
  • Select an option

  • Save kencenerelli/5496290 to your computer and use it in GitHub Desktop.

Select an option

Save kencenerelli/5496290 to your computer and use it in GitHub Desktop.
Interview Question: Verify two strings are anagrams of each other
string one = "hamlet";
char[] a1 = one.ToCharArray();
Array.Sort(a1);
string two = "amleth";
char[] a2 = two.ToCharArray();
Array.Sort(a2);
bool result = false;
if (string.Join("", a1) == string.Join("", a2))
result = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment