public class Solution {
    public int ArrayPairSum(int[] nums) {
        var list = nums.OrderBy(x => x).ToList();
            var sum = 0;
            for (int i = 0; i < list.Count; i += 2)
            {
                sum += list[i];
            }
            return sum;
    }
}

https://leetcode.com/problems/array-partition-i/#/description

posted on 2017-04-24 11:47  Sempron2800+  阅读(93)  评论(0编辑  收藏  举报