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的更多相关文章

  1. LeetCode:455. Assign Cookies

    package Others; import java.util.Arrays; //Question 455. Assign Cookies /* Assume you are an awesome ...

  2. 【leetcode】455. Assign Cookies

    problem 455. Assign Cookies solution1: But, you should give each child at most one cookie. 对小朋友的满意程度 ...

  3. 455. Assign Cookies - LeetCode

    Question 455. Assign Cookies Solution 题目大意:数组g的大小表示有几个小孩,每个元素表示小孩的食量,数组s的大小表示有多少个饼干,每个元素的大小表示每个饼干的大小 ...

  4. 12. leetcode 455.Assign Cookies

    Assume you are an awesome parent and want to give your children some cookies. But, you should give e ...

  5. LeetCode 455. Assign Cookies (分发曲奇饼干)

    Assume you are an awesome parent and want to give your children some cookies. But, you should give e ...

  6. 455. Assign Cookies.md

    Assume you are an awesome parent and want to give your children some cookies. But, you should give e ...

  7. [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 ...

  8. LeetCode 455. Assign Cookies (C++)

    题目: Assume you are an awesome parent and want to give your children some cookies. But, you should gi ...

  9. [leetcode greedy]455. Assign Cookies

    Assume you are an awesome parent and want to give your children some cookies. But, you should give e ...

  10. 455. Assign Cookies 满足欲望 分配饼干

    [抄题]: Assume you are an awesome parent and want to give your children some cookies. But, you should ...

随机推荐

  1. ambassador 学习四 grpc 处理

    实际上都是envoy 的功劳 基本环境安装参考相关文档即可 参考demo proto code syntax = "proto3"; option java_multiple_fi ...

  2. 深入理解java虚拟机,类加载

    1,通过使用静态字段,只有真正定义这个字段的类才会被初始化,(子类不初始化,父类初始化 2,new数组,不初始化 3,通过类来调用一些类的常量,可以不初始化类,(常量在编译期,被优化到NotIniti ...

  3. vue 整合雪碧图功能

    1.通过命令新建一个vue项目 环境要求: 安装有 Node.js. vue. vue-cli . 创建项目: vue init webpack tx_demo cd tx_demo 进入项目,下载依 ...

  4. istio 配置https gateway

    沒有親手實驗,参考官方文档:  https://istio.io/docs/tasks/traffic-management/secure-ingress/

  5. 部分流媒体协议及流媒体开发框架vitamio

    流媒体协议部分RTP.RTCP.RTSP.MMS.HLS.HTTP progressive streaming   流媒体协议:(RTP.RTCP.RTSP.MMS.HLS.HTTP progress ...

  6. -bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory

    -bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory python多版本造成额问题 找不到p ...

  7. windows 下 YII2 配置 memcache

    环境: 操作系统 :Windows 7; php: 5.6.8 apche:2.4.12 1.首先安装PHP  memcache 拓展,安装方法如下: 1.1下载 memcache 拓展DLL: ht ...

  8. zookeeper 节点讲解以及实际项目运用

    转自:https://www.jianshu.com/p/86acf1df6cdd 前言:最近工作不是很忙,本应该乘着闲暇的时间看书的,之前每天晚上都要翻翻的,可是自己竟然迷恋上了王晓磊 写的 卑鄙的 ...

  9. Canvas.Pixels 实例:判断一点是否在区域中

    The Windows 3.1 and Windows 95 GDI heap is limited in regards to scan converting large and complex r ...

  10. Vue SPA应用中使用Layer的iframe 弹出层,并且传值

    问题来源: BOOS 竟然说喜欢有可移动可最大化的弹出层,这!!! SPA 模式下就是这种引入Vue.js的写法 layer.open({ type: , area: ['840px', '550px ...