Leetcode 561) Array Partition I

image

class Solution {
    public int arrayPairSum(int[] nums) {
        Arrays.sort(nums);
        int sum =0;
        int ptr=0;
        while(ptr<nums.length){
            sum+=nums[ptr];
            ptr+=2;
        }
        return sum;
    }
}

© 2018. All rights reserved.

Powered by Hydejack v8.5.2