Skip to content

Instantly share code, notes, and snippets.

@Mirch
Last active September 24, 2019 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mirch/56a4c5897f276c453afac88230b68944 to your computer and use it in GitHub Desktop.
Save Mirch/56a4c5897f276c453afac88230b68944 to your computer and use it in GitHub Desktop.
Duplicates
bool HasDuplicates(int[] items)
{
HashSet<int> appearances = new HashSet<int>();
for (int i = 0; i < items.Length; i++)
{
if (!appearances.Add(items[i]))
{
return true;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment