Skip to content

Instantly share code, notes, and snippets.

@SeanPONeil
Created October 23, 2011 20: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 SeanPONeil/1307875 to your computer and use it in GitHub Desktop.
Save SeanPONeil/1307875 to your computer and use it in GitHub Desktop.
Method to detect duplicates in array of integers in Java
boolean detectDuplicates( int [] x){
Set <Integer> intSet = new HashSet<Integer>();
for( int i: x){
if(intSet.contains(i)){
return true;
}
intSet.add(i);
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment