C++ || sort and two pointers || fast
Approach 1: sort and two pointers\nAfter sorting the input we can use two pointers to loop from the front and back.\n\ncpp\n    double minimumAverage(vector<int
# Approach 1: sort and two pointers\nAfter sorting the input we can use two pointers to loop from the front and back.\n\n```cpp\n    double minimumAverage(vector<int>& nums) {\n        sort(begin(nums), end(nums));\n        double ans = numeric_limits<double>::max();\n        for (int l = 0, r = ssize(nums) - 1; l < r; ++l, --r)\n            ans = min(ans,  0.5 * (nums[l] + nums[r]));\n        return ans;\n    }\n```\n\n**Complexity Analysis**\nLet $$n$$ be the length of the input array ```nums``` then the \n\n* Time complexity is $$O(n \\log n)$$ as we are sorting ```nums```, and the\n\n* Space comlexity is $$O(\\log n)$$ and not $$O(1)$$ because ```std::sort``` is not constant space.\n\n_As always: Feedback, questions, and comments are welcome. Leaving an up-vote sparks joy! :)_\n\n**p.s. Join us on the [LeetCode The Hard Way Discord Server](https://discord.gg/hFUyVyWy2E)!**\n
['C']