博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LeetCode 575. Distribute Candies
阅读量:4624 次
发布时间:2019-06-09

本文共 1032 字,大约阅读时间需要 3 分钟。

Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute these candies equally in number to brother and sister. Return the maximum number of kinds of candies the sister could gain.

Example 1:

Input: candies = [1,1,2,2,3,3]Output: 3Explanation:There are three different kinds of candies (1, 2 and 3), and two candies for each kind.Optimal distribution: The sister has candies [1,2,3] and the brother has candies [1,2,3], too. The sister has three different kinds of candies. `

Example 2:

Input: candies = [1,1,2,3]Output: 2Explanation: For example, the sister has candies [2,3] and the brother has candies [1,1]. The sister has two different kinds of candies, the brother has only one kind of candies.
class Solution {public:    int distributeCandies(vector
& candies) { set
kind; for(int i=0;i

转载于:https://www.cnblogs.com/A-Little-Nut/p/10074013.html

你可能感兴趣的文章
利用docker-machine安装swarm
查看>>
javascript字符类型操作函数
查看>>
thinkphp批量删除的实现
查看>>
请求SpringBoot 服务接口时的中文乱码问题
查看>>
忆少年(七绝)
查看>>
马克思主义与改革(专著)
查看>>
centos7安装hadoop2.6.1,详细教程
查看>>
sql语句select group by order by where一般先后顺序
查看>>
网络1
查看>>
关于jQuery方法解析(一)append-参数设置问题
查看>>
html position display
查看>>
前端学习路线
查看>>
云计算1
查看>>
MVC项目经验杂谈
查看>>
wc命令
查看>>
CentOS下安装mysql及配置使用
查看>>
gevent拾遗
查看>>
Metro学习笔记+心得+体会(四)
查看>>
正则表达式
查看>>
Codeforces Gym 100342H Problem H. Hard Test 构造题,卡迪杰斯特拉
查看>>