Skip to content

Commit cc32244

Browse files
add 1877
1 parent 662ec2f commit cc32244

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|1877|[Minimize Maximum Pair Sum in Array](https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1877.java) ||Medium|Greedy, Sort|
1112
|1876|[Substrings of Size Three with Distinct Characters](https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1876.java) ||Easy|String|
1213
|1869|[Longer Contiguous Segments of Ones than Zeros](https://leetcode.com/problems/longer-contiguous-segments-of-ones-than-zeros/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1869.java) ||Easy|Array, Two Pointers|
1314
|1863|[Sum of All Subset XOR Totals](https://leetcode.com/problems/sum-of-all-subset-xor-totals/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1863.java) ||Easy|Backtracking, Recursion|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.fishercoder.solutions;
2+
3+
import java.util.Arrays;
4+
5+
public class _1877 {
6+
public static class Solution1 {
7+
public int minPairSum(int[] nums) {
8+
Arrays.sort(nums);
9+
int maxSum = 0;
10+
for (int left = 0, right = nums.length - 1; left < right; left++, right--) {
11+
maxSum = Math.max(maxSum, nums[left] + nums[right]);
12+
}
13+
return maxSum;
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)