Note --> Feel free to check the source image below for the original problem statement :)
At a bustling tech company, there are n developers, each with their own set of experience points. The company is gearing up for an exciting hackathon and has come up with a unique way to form pairs of developers for the event. Their plan is to create pairs by matching the developer with the highest experience points with the one with the lowest experience points, and then move inward from both ends.
As the developers are paired, the company is interested in analyzing the combined experience of each pair. The combined experience of a pair is calculated as the average of the experience points of the two developers.
Your challenge is to determine how many unique values there are among these combined experience points.
In simpler terms, given the list of experience points for all developers, you need to find out how many distinct average values result from pairing the highest and lowest remaining experience points iteratively.
Example 1:
Input: exp = [1, 4, 1, 3, 5, 6]
Output: 2
Explanation:Imagine a company with 6 talented developers, each with their own unique set of experience points. As part of an exciting hackathon, the company decides to pair up these developers in a special way. They start by pairing the developer with the highest experience points with the one with the lowest experience points, then continue this process with the remaining developers, moving inward from both ends. For this example, the pairs formed are as follows: The developer with the highest experience points pairs with the one with the lowest: (1, 6). Next, the remaining developers are paired: (1, 5). Finally, the last pair is (4, 3). When calculating the combined experience for each pair, they find the following averages: Pair (1, 6) has a combined experience of 3.5. Pair (1, 5) has a combined experience of 3. Pair (4, 3) also has a combined experience of 3.5. So, among the combined experience values, there are 2 distinct values: 3 and 3.5. Your task is to determine the number of these unique combined experience values, which in this case is 2.
Example 2:
Input: exp = [1, 1, 1, 1, 1, 1]
Output: 1
Explanation:Here’s a storytelling version of the example with developers paired by their indices: In a tech company, there are 6 skilled developers, each with a certain amount of experience. As the company prepares for a hackathon, they decide to pair up the developers in a systematic manner: the first developer pairs with the second, the third with the fourth, and the fifth with the sixth. Here's how the pairs are formed: The first pair consists of developers at indices 0 and 1. The second pair consists of developers at indices 2 and 3. The third pair consists of developers at indices 4 and 5. Each pair's combined experience is calculated by averaging the experience points of the two developers. In this case, every pair ends up with a combined experience of 1. After calculating the combined experiences for all pairs, you find that there's only 1 unique value among them: 1. Thus, the number of distinct combined experience values is 1.
Example 3:
Input: exp = [1, 100, 10, 1000]
Output: 2
Explanation:The In a vibrant tech company, 4 developers are gearing up for a hackathon. To make things interesting, the company decides to pair them up in a unique way. They match the developer at index 0 with the one at index 3, and the developer at index 1 with the one at index 2. Here’s how the pairs are formed: The first pair consists of the developers at indices 0 and 3. The second pair consists of the developers at indices 1 and 2. After calculating the combined experience for each pair, you get: The combined experience for the pair (0, 3) is 500.5. The combined experience for the pair (1, 2) is 55. When you look at these combined experience values, you find that there are 2 distinct values: 500.5 and 55. Thus, the number of unique combined experience values among the pairs is 2.
2 ≤ n ≤ 10^5
0 ≤ exp[i] ≤ 10^9
n
is an even number


input:
output: