Created
January 11, 2015 21:06
-
-
Save dmnugent80/d88170cd3f5ef7374a05 to your computer and use it in GitHub Desktop.
Return count of unique elements in an array
This file contains hidden or 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
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