455. Assign Cookies.md
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a cookie that the child will be content with; and each cookie j has a size sj. If sj >= gi, we can assign the cookie j to the child i, and the child i will be content. Your goal is to maximize the number of your content children and output the maximum number.
Note
You may assume the greed factor is always positive.
You cannot assign more than one cookie to one child.
Example 1
Input: [1,2,3], [1,1]
Output: 1
Explanation: You have 3 children and 2 cookies. The greed factors of 3 children are 1, 2, 3.
And even though you have 2 cookies, since their size is both 1, you could only make the child whose greed factor is 1 content.
You need to output 1.
Example 2
Input: [1,2], [1,2,3]
Output: 2
Explanation: You have 2 children and 3 cookies. The greed factors of 2 children are 1, 2.
You have 3 cookies and their sizes are big enough to gratify all of the children,
You need to output 2.
题目冗长,但是主旨十分的简单;就是给两个数组A,B ,找到A中小于等于B元素的最大个数
public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int num = 0;
        for(int i = 0 ; i < s.length; i++)
            if(num < g.length)
                if(s[i] >= g[num])
                    num ++;
        return num;
    }
												
											455. Assign Cookies.md的更多相关文章
- 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 ...
 - [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 ...
 
随机推荐
- 为什么ERP行业发展缓慢规模难扩大?
			
题记:这个行业只会越来越好,但是能沉淀下来做事儿的企业越来越少,因为收益真的很漫长:能够真正进入这个行业难,出去也难... 经常在知乎上看到类似的问题:既然所有ERP系统都很烂,那有没有创业公司的空间 ...
 - Cocos2D-X屏幕适配新解
			
” 阅读器 为了适应移动终端的各种分辨率大小,各种屏幕宽高比,在 Cocos2D-X(当前稳定版:2.0.4) 中,提供了相应的解决方案,以方便我们在设计游戏时,能够更好的适应不同的环境. 而 ...
 - SSM框架开发web项目系列(二) MyBatis真正的力量
			
前言 上篇SSM框架环境搭建篇,演示了我们进行web开发必不可少的一些配置和准备工作,如果这方面还有疑问的地方,可以先参考上一篇“SSM框架开发web项目系列(一) 环境搭建篇”.本文主要介绍MyBa ...
 - java二进制相关基础
			
转载请注明原创出处,谢谢! 说在前面 之前在JVM菜鸟进阶高手之路十(基础知识开场白)的时候简单提到了二进制相关问题,最近在看RocketMQ的源码的时候,发现涉及二进制的内容蛮多,jdk源码里面也是 ...
 - iOS 图片本地存储、本地获取、本地删除
			
在iOS开发中.经常用到图片的本地化. iOS 图片本地存储.本地获取.本地删除,可以通过以下类方法实现. p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: ...
 - poj 2769 Reduced ID Numbers 同余定理
			
链接:http://poj.org/problem?id=2769 题意:寻找数m,是的对于n个数的余数不同 思路:暴力,优化:同余部分不用测试 代码: #include <iostream&g ...
 - Linux下一次删除百万文件
			
Linux下一次删除百万文件 线上环境遇到的一个问题,文件数量过多,执行rm命令报错 # rm -f ./* -bash: /bin/rm: Argument list too long 根据报错检查 ...
 - TP3.2 图片上传及缩略图
			
基于TP自带的上传文件的类, Think/Upload.class.php 设置表单的enctype属性 下面是上传的具体方法 /** * 图片上传处理 * @param [String] $path ...
 - onunload事件和onbeforeunload事件
			
记录知识点背景:在做一个h5项目时,在统计事件时有这样一个需求, 希望能统计到用户是从第几页离开的,用到了这个知识点.在此记录. window.onunload 1.定义和用法 onunload事件在 ...
 - Java爬虫——网易云热评爬取
			
爬取目标网址 : http://music.163.com/#/song?id=409649818 需要爬取信息 : 网易云top13热评 使用之前的 HttpURLConnection 获取 ...