原题

Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), …, (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as possible.

Example 1:
Input: [1,4,3,2]Output: 4
Explanation: n is 2, and the maximum sum of pairs is 4.

代码实现

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

leetcode-solution库

leetcode算法题目解决方案每天更新在github库中,欢迎感兴趣的朋友加入进来,也欢迎star,或pull request。https://github.com/jackzhenguo/leetcode-csharp

561. Array Partition I相关推荐

  1. Leetcode PHP题解--D14 561. Array Partition I

    561. Array Partition I 题目链接 561. Array Partition I 题目分析 本题给了一个数组,要求将数组分为n个只有2个元素的一对. 使得每对数字中最小的数加起来的 ...

  2. Leetcode刷题记录[java]——561 Array Partition I

    一.前言 二.题561 Array Partition I Given an array of 2n integers, your task is to group these integers in ...

  3. [LeetCode]561. Array Partition I (数组分区 1)

    561. Array Partition I Given an array of 2n integers, your task is to group these integers into n pa ...

  4. 561.Array Partition I--Python

    刚开始学习Python编程,欢迎交流学习! 561.Array Partition I Given an array of 2n integers, your task is to group the ...

  5. LeetCode 561. Array Partition I

    题目: Given an array of 2n integers, your task is to group these integers into n pairs of integer, say ...

  6. LeetCode 561 Array Partition I(数组划分)

    翻译 原文 Given an array of 2n integers, your task is to group these integers into n pairs of integer, s ...

  7. leetcode#561 Array Partition I

    Description: Given an array of 2n integers, your task is to group these integers into n pairs of int ...

  8. 【刷leetcode,拿Offer-009】561. Array Partition I(贪心,C++)

    题目链接 Given an array of 2n integers, your task is to group these integers into n pairs of integer, sa ...

  9. 561. 数组拆分 I(javascript)561. Array Partition I

    给定长度为 2n 的整数数组 nums ,你的任务是将这些数分成 n 对, 例如 (a1, b1), (a2, b2), -, (an, bn) ,使得从 1 到 n 的 min(ai, bi) 总和 ...

最新文章

  1. AD环境部署文件服务器2012,Windows_server_2012部署AD域及辅域环境.doc
  2. Javascript函数和事件
  3. 北斗导航 | GPS卫星导航技术重要人物简介
  4. python监控键盘输入_Python实现监控键盘鼠标操作示例【基于pyHook与pythoncom模块】...
  5. 排序与查找 详细分析
  6. C++常见面试题(2019年校招总结)
  7. java打印已经被加载的类_使用URLClassLoader加载类,不会报错,但被加载类中的内容也没有打印出来...
  8. Destoon数据库配置文件在哪_Mybatis 系列 2:Mybatis 的两种配置文件
  9. js之数据类型的比较
  10. GBDT算法之流失预警模型
  11. 路由器工作模式Classless与Classful实验分析
  12. BTC:做空是有规律可循的,目前熊族正沿着这个回调线位做空
  13. 北京2020积分落户名单
  14. JAVA、android常用时间处理方法及类似微信微博发表时间显示
  15. SQL编程-组队学习打卡task06-秋招秘籍ABC
  16. 达内python第一次月考题目_第一次月考总结
  17. ValueError: Solver lbfgs supports only ‘l2‘ or ‘none‘ penalties, got l1 penalty.
  18. 过万 star 高星项目的秘密——GitHub 热点速览 Vol.39
  19. 基于springboot供应链管理系统毕业设计源码121518
  20. 关于如何用WORD实现图片转文字

热门文章

  1. 【傅里叶级数】-----向量/三角函数的正交性
  2. 【数据库】彻底理解外键的作用
  3. Java 定义一个人类Person
  4. LIB,DLL区别 及 QT中如何添加LIB,DLL
  5. 线性代数-01矩阵与行列式
  6. branca.colormap自带的json文件对颜色的定义
  7. linux驱动设备开发1——字符设备驱动
  8. 机器学习——决策树算法的应用
  9. strtod() 函数
  10. SDK Manager安装