Sorting ✅ | Simple Short Approach 💯 | Easy to Understand 🔥 | Beginner Friendly Code | C++
Approach\n1. sort the array with time complexity of O(nlogn).\n2. for loop till the middle of the array so that we can average the max and min values of the sor
# Approach\n1. sort the array with time complexity of O(nlogn).\n2. for loop till the middle of the array so that we can average the max and min values of the sorted array considering it\'s ends. \n(**nums[i] & nums[n-i-1]**)\n3. Above step takes O(n/2).\n4. Get the minimum value of averages and keep on updating.\n\n# Complexity\n- Time complexity: O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    double minimumAverage(vector<int>& nums) {\n        int n = nums.size();\n        double minavg = INT_MAX;\n        sort(nums.begin(), nums.end());\n        for(int i=0; i<n/2; i++){\n            double avg = (nums[i]+nums[n-i-1])*1.0/2.0;\n            minavg = min(minavg, avg);\n        }\n        return minavg;\n    }\n};\n```
['Sorting', 'C++']