BYTELEARN Hiring | Number of Distinct Averages | On-Campus OA (2024)

Question · Posted Jun 2026

Problem Statement You are given an even-length integer array nums. Repeatedly perform the following operation until the array becomes empty: Remove the minimum element. Remove the maximum element. Compute their average. Return the number of distinct averages obtained during this process. Example Input nums = [4,1,4,0,3,5] Output 2 Explanation After sorting: [0,1,3,4,4,5] Pairs formed: (0,5) → 2.5 (1,4) → 2.5 (3,4) → 3.5 Distinct averages: {2.5, 3.5} Count = 2 Constraints 2 <= nums.length <= 100 nums.length is even 0 ...

The full answer & interview discussion are available to premium members.

Log in Create a free account