Optimal solution in cpp
IntuitionApproachYou can easily find a minimum average by sorting the array.
No need to store all average in a vector which leads to O(N) space complexity.The a
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->
You can easily find a minimum average by sorting the array.
No need to store all average in a vector **which leads to O(N) space complexity**.

The approach below is , best optimal approach to find minimum average from array ...
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(N log N)$$ -->
**O(N log N)**

- Space complexity:
<!-- Add your space complexity here, e.g. $$O()$$ -->
**O(1)**

# Code
```cpp []
class Solution {
public:
    double minimumAverage(vector<int>& nums) {
        double minAvg = DBL_MAX;

        sort(nums.begin(), nums.end());

        for (int i = 0; i < nums.size() / 2; i++) {
            double avg = (nums[i] + nums[nums.size() - i - 1]) / 2.0;
            minAvg = min(minAvg, avg);
        }

        return minAvg;
    }
};
```
['Sorting', 'C++']