一定要早日上岸鸭 · July 19, 2021 0

1877. 数组中最大数对和的最小值

1877. 数组中最大数对和的最小值

class Solution { public int minPairSum(int[] nums) { Arrays.sort(nums); int[] storage = new int[nums.length/2+10]; int left = 0, right = nums.length-1; int ans =0; while(right>left){ storage[left] = nums[left++]+nums[right--]; } for(int i:storage){ ans = Math.max(ans, i); } return ans; } }