Skip to content

Latest commit

 

History

History
22 lines (17 loc) · 437 Bytes

Question_561.md

File metadata and controls

22 lines (17 loc) · 437 Bytes

LeetCode Records - Question 561 Array Partition

Attempt 1: Sort the array first

class Solution {
    public int arrayPairSum(int[] nums) {
        Arrays.sort(nums);

        int count = 0;
        
        for (int i = 0; i < nums.length - 1; i += 2) {
            count += nums[i];
        }

        return count;
    }
}
  • Runtime: 12 ms (Beats: 97.01%)
  • Memory: 46.58 MB (Beats: 41.16%)