Last active
September 24, 2019 08:49
-
-
Save Mirch/56a4c5897f276c453afac88230b68944 to your computer and use it in GitHub Desktop.
Duplicates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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