C# O(nlogn) Solution


  • 0
    J
    public int ArrayPairSum(int[] nums)
    {
           Array.Sort(nums);
           int sum = 0;
           for (var i=0;i<nums.Length;i+=2)
           {
                 sum += nums[i];
           }
    
           return sum;
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.