simple java 4lines code


  • 0
    L

    simple question

    public int arrayPairSum(int[] nums) {
            Arrays.sort(nums);
            int result=0;
            for(int i=0;i<nums.length/2;i++){
                result=result+nums[i*2];
            }
            
            return result;
        }
    

Log in to reply
 

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