@@ -0,0 +1,1284 @@
+/**%0A *Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute these candies equally in number to brother and sister. Return the maximum number of kinds of candies the sister could gain.%0A *%0A *Example 1:%0A *Input: candies = %5B1,1,2,2,3,3%5D%0A *Output: 3%0A *Explanation:%0A *There are three different kinds of candies (1, 2 and 3), and two candies for each kind.%0A *Optimal distribution: The sister has candies %5B1,2,3%5D and the brother has candies %5B1,2,3%5D, too. %0A *The sister has three different kinds of candies. %0A *Example 2:%0A *Input: candies = %5B1,1,2,3%5D%0A *Output: 2%0A *Explanation: For example, the sister has candies %5B2,3%5D and the brother has candies %5B1,1%5D. %0A *The sister has two different kinds of candies, the brother has only one kind of candies. %0A *Note:%0A *%0A *The length of the given array is in range %5B2, 10,000%5D, and will be even.%0A *The number in given array is in range %5B-100,000, 100,000%5D.%0A *%0A */%0Aclass Solution %7B%0A    public int distributeCandies(int%5B%5D candies) %7B%0A        Set%3CInteger%3E set = new HashSet%3C%3E();%0A        for (int candy : candies) %7B%0A            set.add(candy);%0A        %7D%0A        return Math.min(set.size(), candies.length / 2);%0A    %7D%0A%7D%0A

Create DistributeCandies.java