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 }

 

posted @ 2020-03-02 16:20  SheepCore  阅读(118)  评论(0编辑  收藏  举报