561. Array Partition
Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 80% Topics: Array, Greedy, Sorting, Counting Sort
View full problem on LeetCode Reading material
Reference solution (spoiler · java)
import java.util.*;
class Solution {
int arrayPairSum(int[] nums) {
Arrays.sort(nums);
int result = 0;
for (int i = 0; i < nums.length; i += 2) {
result += nums[i];
}
return result;
}
}
Solution from kamyu104/LeetCode-Solutions · MIT