MCPcopy Create free account
hub / github.com/ROUTINE-STUDY/Algorithm / arrayPairSum

Function arrayPairSum

LeetCode/Greedy/561. Array Partition I/JaeHong.js:1–10  ·  view source on GitHub ↗
(nums)

Source from the content-addressed store, hash-verified

1var arrayPairSum = function (nums) {
2 nums.sort((a, b) => a - b);
3 let result = 0;
4
5 for (let i = 0; i < nums.length; i += 2) {
6 result += nums[i];
7 }
8
9 return result;
10};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected