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. prisma graphql 集成timescaledb

    prisma 官方文档说明了因为支持pg 所以相关的timescaledb.cockroachdb 应该也是支持的 但是测试之后timescaledb 支持cockroachdb有问题(事务处理模型支 ...

  2. memsql filesystem pipeline 试用

    一些功能类似drill ,比如s3,file ... 创建file pipeline 准备file mkdir -p /opt/db/ touch books.txt 内容如下: The Catche ...

  3. C# Socket笔记

    看到这个题目,是不是很眼熟?在博客园里搜下,保证会发现关于这个东东的文章实在是太多了~~~真得是没有写得必要,而且我也有点懒得去琢磨字句.(看到这,肯定得来个转折的了,不然就看不到下文了,不是吗)但是 ...

  4. ASP.NET 获得当前网页名字

    Code string currentFilePath = HttpContext.Current.Request.FilePath; string CurrentPageName = current ...

  5. 32位汇编基础_内存_每个应用进程都会有自己独立的4GB内存空间

    1.每个应用进程都会有自己独立的4GB内存空间 这句话很多人听起来可能会很矛盾很不解. 例如,我的电脑只有2GB的内存,打开个软件机会占用4GB内存,而我的电脑内存只有2GB,显然不够用,但是为什么程 ...

  6. VMware vSphere Client下增加虚拟机磁盘空间的方法

    随着系统运维时间的增长,磁盘就日益的损耗,如果遇到虚拟机报磁盘空间不足怎么办?还好,我们可以通过磁盘阵列增加磁盘空间,然后扩容到虚拟机中去. 对于linux虚拟机磁盘扩容的方案有两种,一种就是原有的实 ...

  7. Solr Suggest组件的使用

    使用suggest的原因,最主要就是相比于search速度快,In general, we need the autosuggest feature to satisfy two main requi ...

  8. python + docker, 实现天气数据 从FTP获取以及持久化(四)-- 数据准备

    前情提要 在之前的文章里,我们已经掌握从FTP上面下载天气数据然后插入到数据库中. 但是如何将我们已有的数据放到生产环境中呢? 思考 首先,我们先简单的理一理现在的情况. 目前: FTP上面已有半个月 ...

  9. 安装 sass 文档

    为什么使用Sass 作为前端(html.javascript.css)的三大马车之一的css,一直以静态语言存在,HTML5火遍大江南北了.javascript由于NODE.JS而成为目前前后端统一开 ...

  10. Java HashMap 遍历方式探讨

    JDK8之前,可以使用keySet或者entrySet来遍历HashMap,JDK8中引入了map.foreach来进行遍历. keySet其实是遍历了2次,一次是转为Iterator对象,另一次是从 ...