Solution 1
- TimeO(n log n)
- SpaceO(1) (Assuming, sorted nums is not considered)
where, n is the length of nums
Solved in 4 mins 36 secs, all by yourself! Good job!
Python · 2026-01-24
class Solution:
'''
Time Complexity: O(n log n)
Space Complexity: O(1) (Assuming, sorted nums is not considered)
where, n is the length of nums
Solved in 4 mins 36 secs, all by yourself! Good job!
'''
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
res = 0
l, r = 0, len(nums)-1
while l < r:
res = max(res,nums[l]+nums[r])
l += 1
r -= 1
return res