JAVA_Array Partition_LeetCode 561


JAVA_Array Partition_LeetCode 561

JAVA_Array Partition_LeetCode 561 풀이 class Solution { public int arrayPairSum(int[] nums) { Arrays.sort(nums); int result = 0; for(int num = 0; num < nums.length; num += 2){ result += nums[num]; } return result; } } * 출처 Array Partition - LeetCode Array Partition - Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the sum of min(ai, bi) for all i is maximized. Return the maximized sum. Example 1: Input: nums = [1,4,3,2] Outp...


#ArrayPartition_LeetCode561 #JAVA #JAVA_ArrayPartition #JAVA_ArrayPartition_LeetCode561 #JAVA_LeetCode561

원문링크 : JAVA_Array Partition_LeetCode 561