12. leetcode 455.Assign Cookies
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.
思路:由于一个孩子只能给一个,所以先把两个数组分别排序,然后逐个比对。

12. leetcode 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 (分发曲奇饼干)
		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: 455 Assign Cookies(easy)
		题目: Assume you are an awesome parent and want to give your children some cookies. But, you should gi ... 
- 【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的大小表示有多少个饼干,每个元素的大小表示每个饼干的大小 ... 
- 【LeetCode】455. Assign Cookies 解题报告(Java & Python)
		作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 Java解法 Python解法 日期 [LeetCo ... 
- [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 greedy]455. Assign Cookies
		Assume you are an awesome parent and want to give your children some cookies. But, you should give e ... 
随机推荐
- Microsoft Excel 自动取数据库数据
			1.下载安装mysql-connector-odbc-5.1.5-win32.msi 2.打开控制面板.搜索数据 3.点击添加→MySQL ODBC 5.1 Driver→完成 4.填写名称.IP地址 ... 
- C++ 安全单例模式总结
			前两天,一个C++ 的单例实现又掉坑里了.做好一个安全的单例模式可并不简单.这里总结一下C++ 的几个单例实现方案. 1. 函数静态变量法 利用单例函数的静态变量,实现单例构造.代码如下: class ... 
- Mac机上安装nvm遇到的坑--nvm command not found
			在Mac机上,我最开始是通过homebrew来安装nvm,如下: $ brew install nvm 安装完成后,在命令行输入nvm list,发现出现如下提示: What?!!我不是才安装了nvm ... 
- java设计模式综合项目实战视频教程
			java设计模式综合项目实战视频教程 视频课程目录如下: 第01节课:本课程整体内容介绍:X-gen系统概况,包括:引入.X-gen项目背景.X-gen的HelloWorld第02节课:X-gen整体 ... 
- explode和implode的运用
			$kesu_list=DD('Kesu.Kesu')->kesu_list(); foreach($kesu_list[0] as $key=>$val){ $reason_id_list ... 
- Python进阶 - 命名空间与作用域
			Python进阶 - 命名空间与作用域 写在前面 如非特别说明,下文均基于Python3 命名空间与作用于跟名字的绑定相关性很大,可以结合另一篇介绍Python名字.对象及其绑定的文章. 1. 命名空 ... 
- 13.localStorage和sessionStorage的区别
			HTMl5的sessionStorage和localStorage html5中的Web Storage包括了两种存储方式:sessionStorage和localStorage. sessionSt ... 
- 打开vmvare出现The VMware Authorization Service is not running。
			win+r再输入cmd打开doc,输入services.msc打开服务,吧Vmware Authorization Service 更改为自动或者将其启动即可. 
- web拖动条显示
			<!DOCTYPE html"> <html> <head> <title>滚动条拖动评分的JS效果</title> <st ... 
- EXT 基础环境搭建
			EXT 基础环境搭建使用 Sencha CMD 下载地址 https://www.sencha.com/products/extjs/cmd-download/ Sencha CMD 常用命令 API ... 
