LeetCode-561 Array Partition I Solution (with Java)

1. Description:


Notes:

2. Examples:

3.Solutions:

 1 /**
 2  * Created by sheepcore on 2019-02-24
 3  */
 4 class Solution {
 5     public int arrayPairSum(int[] nums) {
 6         Arrays.sort(nums);
 7         int res = 0;
 8         for (int i = 0; i < nums.length; i += 2) {
 9             res += nums[i];
10         }
11         return res;
12     }
13 }

猜你喜欢

转载自www.cnblogs.com/sheepcore/p/12396258.html