Number of Distinct Averages Problem
Number of Distinct Averages Problem — ExecCode Easy DSA Practice
Solve the Number of Distinct Averages problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given a 0-indexed integer array nums of even length. Your task is to - Find the minimum number in nums and remove it. As long as nums is not empty, you must repetitively: - Find the maximum number in nums and remove it. - Calculate the average of the two removed numbers. The average of two numbers a and b is (a + b) / 2. Return the required answer exactly as shown in the examples.
Examples
Input {"nums": [4, 1, 4, 0, 3, 5]}; Output 2. Input {"nums": [1, 100]}; Output 1
Constraints
2 <= nums.length <= 100 nums.length is even. 0 <= nums[i] <= 100
Practice Number of Distinct Averages free on ExecCode. Browse DSA problems, topic map, and placement guides.