#3194

Minimum Average of Smallest and Largest Elements

newbie · 130 · lc easy +13 · 85.3% accepted · 204 likes · top 96%

Description

Start with an empty floating-point array averages. You are given an integer array nums of even length n.

Repeat the following n / 2 times:

- Remove the smallest element minElement and the largest element maxElement from nums.

- Append (minElement + maxElement) / 2 to averages.

Return the minimum value in averages.

Code

1
2
3