-
Notifications
You must be signed in to change notification settings - Fork 160
/
distribute-candies.md
28 lines (25 loc) · 1.17 KB
/
distribute-candies.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Given an integer array with <b>even</b> length, where different numbers in this array represent different <b>kinds</b> of candies. Each number means one candy of the corresponding kind. You need to distribute these candies <b>equally</b> in number to brother and sister. Return the maximum number of <b>kinds</b> of candies the sister could gain.
<p><b>Example 1:</b><br />
<pre>
<b>Input:</b> candies = [1,1,2,2,3,3]
<b>Output:</b> 3
<b>Explanation:</b>
There are three different kinds of candies (1, 2 and 3), and two candies for each kind.
Optimal distribution: The sister has candies [1,2,3] and the brother has candies [1,2,3], too.
The sister has three different kinds of candies.
</pre>
</p>
<p><b>Example 2:</b><br />
<pre>
<b>Input:</b> candies = [1,1,2,3]
<b>Output:</b> 2
<b>Explanation:</b> For example, the sister has candies [2,3] and the brother has candies [1,1].
The sister has two different kinds of candies, the brother has only one kind of candies.
</pre>
</p>
<p><b>Note:</b>
<ol>
<li>The length of the given array is in range [2, 10,000], and will be even.</li>
<li>The number in given array is in range [-100,000, 100,000].</li>
<ol>
</p>