AmazonOA #373
Let's Play Crush Fruit Together :)
Estimated MediumJudge-ready
In each step, pick one fruit from each of two different types and delete both; they do not need to be adjacent. You cannot delete a pair of the same type. Find the minimum number of fruits left.
Input
The first line contains n and the second line contains n type integers. The original bounds are 1≤n≤100000, 1≤type≤10^9.
Output
Output a single integer, the answer.
Example 1
Input:
5
3 3 1 1 2
Output:
1
Example 2
Input:
4
1 2 5 6
Output:
0
Example 3
Input:
4
7 7 7 1
Output:
2
Example notes
The outputs of the three public examples are 1; 0; and 2, checked by independent enumeration or direct simulation.
Editorial
Loading solution…