Skip to main content
Back to problems
#1877
Medium Algorithms

Minimize maximum pair sum in array

Array Two Pointers Greedy Sorting
83.3% acceptance
Feb 25, 2026
2366
546
Given an array nums of even length n, pair up the elements of nums into n / 2 pairs such that the maximum pair sum is minimized. Return the minimized maximum pair sum.

Solution

Rust
Time O(n log n)
Space O(1)
LeetCode
solution.rs
impl Solution {
  pub fn min_pair_sum(mut nums: Vec<i32>) -> i32 {
    nums.sort_unstable();
    let n = nums.len();
    (0..n / 2).map(|i| nums[i] + nums[n - 1 - i]).max().unwrap()
  }
}