Last active
September 11, 2016 14:59
-
-
Save arielm/66cedfce8ebe908f10549fe66fcdd5bc to your computer and use it in GitHub Desktop.
Solution (100%) to Distinct problem on Codility (https://codility.com/programmers/task/distinct/)
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
/* | |
* EASIEST TEST OF ALL SO FAR... | |
*/ | |
import java.util.*; | |
class Solution | |
{ | |
public int solution(int[] A) | |
{ | |
TreeSet<Integer> distinctValues = new TreeSet<Integer>(); | |
for (int i = 0; i < A.length; i++) | |
{ | |
distinctValues.add(A[i]); | |
} | |
return distinctValues.size(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment