561. Array Partition I
原题
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相关推荐
- Leetcode PHP题解--D14 561. Array Partition I
561. Array Partition I 题目链接 561. Array Partition I 题目分析 本题给了一个数组,要求将数组分为n个只有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 ...
- [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 ...
- 561.Array Partition I--Python
刚开始学习Python编程,欢迎交流学习! 561.Array Partition I Given an array of 2n integers, your task is to group the ...
- LeetCode 561. Array Partition I
题目: Given an array of 2n integers, your task is to group these integers into n pairs of integer, say ...
- LeetCode 561 Array Partition I(数组划分)
翻译 原文 Given an array of 2n integers, your task is to group these integers into n pairs of integer, s ...
- leetcode#561 Array Partition I
Description: Given an array of 2n integers, your task is to group these integers into n pairs of int ...
- 【刷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 ...
- 561. 数组拆分 I(javascript)561. Array Partition I
给定长度为 2n 的整数数组 nums ,你的任务是将这些数分成 n 对, 例如 (a1, b1), (a2, b2), -, (an, bn) ,使得从 1 到 n 的 min(ai, bi) 总和 ...
最新文章
- AD环境部署文件服务器2012,Windows_server_2012部署AD域及辅域环境.doc
- Javascript函数和事件
- 北斗导航 | GPS卫星导航技术重要人物简介
- python监控键盘输入_Python实现监控键盘鼠标操作示例【基于pyHook与pythoncom模块】...
- 排序与查找 详细分析
- C++常见面试题(2019年校招总结)
- java打印已经被加载的类_使用URLClassLoader加载类,不会报错,但被加载类中的内容也没有打印出来...
- Destoon数据库配置文件在哪_Mybatis 系列 2:Mybatis 的两种配置文件
- js之数据类型的比较
- GBDT算法之流失预警模型
- 路由器工作模式Classless与Classful实验分析
- BTC:做空是有规律可循的,目前熊族正沿着这个回调线位做空
- 北京2020积分落户名单
- JAVA、android常用时间处理方法及类似微信微博发表时间显示
- SQL编程-组队学习打卡task06-秋招秘籍ABC
- 达内python第一次月考题目_第一次月考总结
- ValueError: Solver lbfgs supports only ‘l2‘ or ‘none‘ penalties, got l1 penalty.
- 过万 star 高星项目的秘密——GitHub 热点速览 Vol.39
- 基于springboot供应链管理系统毕业设计源码121518
- 关于如何用WORD实现图片转文字