AmazonOA #192
Find Unique Values
Estimated EasyJudge-ready
Topics (AI-labelled)Two PointersHashing
Repeatedly pair the people with the smallest and the largest remaining experience into a group and remove both, until everyone is paired. Find the number of distinct values among the groups' average experience.
Input
The first line contains an even n; the second line contains the experience values. 2≤n≤100000 and n is even; 1≤experience≤10^9.
Output
Output a single integer, the answer.
Example 1
Input:
6
1 4 1 3 5 6
Output:
2
Example 2
Input:
6
1 1 1 1 1 1
Output:
1
Example 3
Input:
4
1 100 10 1000
Output:
2
Example notes
The answers are 2, 1 and 2.
Editorial
Loading solution…