3194. Minimum Average of Smallest and Largest Elements
Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 85% Topics: Array, Two Pointers, Sorting
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(nlogn)
# Space: O(1)
# sort
class Solution(object):
def minimumAverage(self, nums):
"""
:type nums: List[int]
:rtype: float
"""
nums.sort()
return min((nums[i]+nums[~i])/2.0 for i in xrange(len(nums)//2))
Solution from kamyu104/LeetCode-Solutions · MIT
Similar questions