Skip to content

Instantly share code, notes, and snippets.

@arielm
Last active September 11, 2016 14:59
Show Gist options
  • Save arielm/66cedfce8ebe908f10549fe66fcdd5bc to your computer and use it in GitHub Desktop.
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/)
/*
* 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