Tap here to switch tabs
Problem
Submissions

Problem: Number of Distinct Averages

med
30 min
Try to solve the Number of Distinct Averages problem.

Statement

You are given an integer array nums of even length.

As long as nums is not empty, perform the following operation:

  1. Find and remove the minimum value in nums.

  2. Find and remove the maximum value in nums.

  3. Compute the average of the pair of removed numbers.

Return the total number of distinct averages obtained from this process.

Note: The average of two numbers aa and bb is computed as a+b2\frac{a + b}{2}.

Constraints:

  • 2≤2 \leq nums.length ≤100\leq 100

  • nums.length is even.

  • 0≤0 \leq nums[i] ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Distinct Averages

med
30 min
Try to solve the Number of Distinct Averages problem.

Statement

You are given an integer array nums of even length.

As long as nums is not empty, perform the following operation:

  1. Find and remove the minimum value in nums.

  2. Find and remove the maximum value in nums.

  3. Compute the average of the pair of removed numbers.

Return the total number of distinct averages obtained from this process.

Note: The average of two numbers aa and bb is computed as a+b2\frac{a + b}{2}.

Constraints:

  • 2≤2 \leq nums.length ≤100\leq 100

  • nums.length is even.

  • 0≤0 \leq nums[i] ≤100\leq 100