Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    3194 - Minimum Average of Smallest and Largest Elements\.

    Easy

    You have an array of floating point numbers averages which is initially empty. You are given an array nums of n integers where n is even.

    You repeat the following procedure n / 2 times:

    • Remove the smallest element, minElement, and the largest element maxElement, from nums.

    • Add (minElement + maxElement) / 2 to averages.

    Return the minimum element in averages.

    Example 1:

    Input: nums = 7,8,3,4,15,13,4,1

    Output: 5.5

    Explanation:

    The smallest element of averages, 5.5, is returned.

    Example 2:

    Input: nums = 1,9,8,3,10,5

    Output: 5.5

    Explanation:

    Example 3:

    Input: nums = 1,2,3,7,8,9

    Output: 5.0

    Explanation:

    Constraints:

    • 2 <= n == nums.length <= 50

    • n is even.

    • 1 <= nums[i] <= 50

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Double minimumAverage(IntArray nums)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait