Skip to content

Instantly share code, notes, and snippets.

@dmnugent80
Created January 11, 2015 21:06
Show Gist options
  • Save dmnugent80/d88170cd3f5ef7374a05 to your computer and use it in GitHub Desktop.
Save dmnugent80/d88170cd3f5ef7374a05 to your computer and use it in GitHub Desktop.
Return count of unique elements in an array
public int getUniqueCount(int[] array){
ArrayList<Integer> arrUnique = new ArrayList<Integer>();
for (int i=0; i < array.length; i++){
if (!arrUnique.contains(array[i]){
arrUnique.add(array[i]);
}
}
return arrUnique.size();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment