100% Beats | C++ Solution | Simple | Beginner Friendly Code 
IntuitionThe goal is to find the minimum average value obtained by pairing the smallest and largest elements of a given array. The intuition is that after sorti
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The goal is to find the minimum average value obtained by pairing the smallest and largest elements of a given array. The intuition is that after sorting the array, pairing the smallest and largest elements minimizes the difference between the pair values, thus minimizing the average value of each pair. We repeat this process for all elements until no pairs are left.

# Approach
<!-- Describe your approach to solving the problem. -->
1. Sort the Array:
The input array is sorted in ascending order to efficiently access the smallest and largest numbers.
2. Iterative Pairing:
Use the smallest element (nums.front()) and the largest element (nums.back()).
Compute their average and store it in a vector (avg).
Remove the processed elements using erase and pop_back() to continue with the next smallest and largest pair.
3. Find the Minimum Average:
After processing all pairs, use min_element on the avg vector to find the smallest average.
4. Return the Result:
Return the minimum average computed.

# Code
```cpp []
class Solution {
public:
    double minimumAverage(vector<int>& nums) {
        sort(nums.begin(),nums.end());
        vector<double> avg;
        while(!nums.empty())
        {
            int min=nums.front();
            nums.erase(nums.begin());
            int max=nums.back();
            nums.pop_back();  // or use this -- nums.erase(nums.end()); but this will not beats 100%
            avg.push_back((min+max)/2.0);
        }

        return *min_element(avg.begin(),avg.end());
    }
};
```
['C++']