Skip to main content
Back to problems
Leetcode
Medium
Arrays
Sorting
Math
Minimum Average Of Smallest And Largest Elements

Find the smallest possible average formed by pairing the minimum and maximum values from a list.

Acceptance 0%
Problem Statement

Problem

Given an array of numbers, repeatedly consider the smallest and largest remaining elements as a pair and compute their average. Your task is to determine the minimum average among all such pairings.

In the standard interpretation of this problem, you do not need to construct all pairs explicitly. You only need to identify the pair consisting of the current smallest and largest values, compute their average, and return the minimum average seen across the relevant pairings.

This problem mainly tests whether you can reason about extremes in an array and process values efficiently.

Input Format

  • An integer array nums.
  • The array contains at least one number.

Output Format

  • Return a number representing the minimum average value derived from the relevant smallest/largest pairing logic.

Constraints

  • The exact constraints depend on the platform version.
  • A linear-time pass or an O(nlogn)O(n \log n) approach should be sufficient for typical interview settings.
  • Use safe numeric handling for averages.
Examples
Sample cases returned by the problem API.

Example 1

Input

nums = [7, 8, 3, 4, 15, 13, 4, 1]

Output

6.0

Explanation

The smallest and largest values are 1 and 15, giving an average of 8.0. If the intended task is to evaluate all paired extremes after sorting, the minimum relevant average comes from the smallest/largest pair among the considered elements. This example is illustrative of the extreme-pairing idea.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.