455. Assign Cookies
static int wing=[]()
{
std::ios::sync_with_stdio(false);
cin.tie(NULL);
return ;
}(); class Solution
{
public:
int findContentChildren(vector<int>& g, vector<int>& s)
{
int szchild=g.size();
int szcookies=s.size();
if(szchild==||szcookies==)
return ;
sort(g.begin(),g.end());
sort(s.begin(),s.end());
int indexchild=,indexcookies=;
int count=;
while(indexchild<szchild&&indexcookies<szcookies)
{
if(s[indexcookies]>=g[indexchild])
{
count++;
indexcookies++;
indexchild++;
}
else
indexcookies++;
}
return count;
}
};
排个序,俩数组元素扫描比较即可。
455. Assign Cookies的更多相关文章
- LeetCode:455. Assign Cookies
package Others; import java.util.Arrays; //Question 455. Assign Cookies /* Assume you are an awesome ...
- 【leetcode】455. Assign Cookies
problem 455. Assign Cookies solution1: But, you should give each child at most one cookie. 对小朋友的满意程度 ...
- 455. Assign Cookies - LeetCode
Question 455. Assign Cookies Solution 题目大意:数组g的大小表示有几个小孩,每个元素表示小孩的食量,数组s的大小表示有多少个饼干,每个元素的大小表示每个饼干的大小 ...
- 12. leetcode 455.Assign Cookies
Assume you are an awesome parent and want to give your children some cookies. But, you should give e ...
- LeetCode 455. Assign Cookies (分发曲奇饼干)
Assume you are an awesome parent and want to give your children some cookies. But, you should give e ...
- 455. Assign Cookies.md
Assume you are an awesome parent and want to give your children some cookies. But, you should give e ...
- [LeetCode&Python] Problem 455. Assign Cookies
Assume you are an awesome parent and want to give your children some cookies. But, you should give e ...
- LeetCode 455. Assign Cookies (C++)
题目: Assume you are an awesome parent and want to give your children some cookies. But, you should gi ...
- [leetcode greedy]455. Assign Cookies
Assume you are an awesome parent and want to give your children some cookies. But, you should give e ...
- 455. Assign Cookies 满足欲望 分配饼干
[抄题]: Assume you are an awesome parent and want to give your children some cookies. But, you should ...
随机推荐
- mac终端下修改MySQL的编码格式--找不到my-default.cnf及my.cnf
首先请确认正确安装好MySQL. 1- 先配置环境变量path 1.1 打开终端,输入: cd ~ 会进入~文件夹, 1.2 然后输入:touch .bash_profile 回车执行后, 1.3 再 ...
- 使用ajax提交form表单,包括ajax文件上传 转http://www.cnblogs.com/zhuxiaojie/p/4783939.html
使用ajax提交form表单,包括ajax文件上传 前言 使用ajax请求数据,很多人都会,比如说: $.post(path,{data:data},function(data){ ... },&qu ...
- Linux交叉编译工具链和模块编译
所有的工具: aarch64-poky-linux-addr2line aarch64-poky-linux-c++filt aarch64-poky-linux-g++ aarch64-poky-l ...
- 什么是HBase(六)性能调优
硬件层面 内存要大,最好是ECC(Error Checking and Correcting),实现内存的动态纠错:CPU要多路(每个路彼此隔离)每个路一个CPU,每个cpu上面一般都是2~12核. ...
- servlet深探
在spring4下面使用的是ServletContext作为容器,这个是servlet规范里面设置的:加载了默认的servlet(在spring 4之前都是web.xml中做的),但是在spring ...
- mschart 使用心得和部署。
参考: http://www.cnblogs.com/suguoqiang/archive/2013/01/16/2862945.html 1.在统计时可能需要多条数据,需要整合数据源 Chart1. ...
- linux 线程的同步 三 (内存信号量的使用)
信号量.同步这些名词在进程间通信时就已经说过,在这里它们的意思是相同的,只不过是同步的对象不同而已.但是下面介绍的信号量的接口是用于线程的信号量,注意不要跟用于进程间通信的信号量混淆,关于用于进程间通 ...
- Django 组件-分页器
Django的分页器(paginator) view from django.shortcuts import render,HttpResponse # Create your views here ...
- expect学习笔记及用法
expect学习笔记及实例详解 expect的基本用法 expect用法
- 第八章(三)基于Listcheck适配器的访问控
denier适配器访问控制比较死板.Listchecker的适配器更加灵活. 定义handler: apiVersion: config.istio.io/v1alpha2 kind: listche ...