leetcode455
public class Solution {
public int FindContentChildren(int[] g, int[] s) {
var listg = g.OrderBy(x => x).ToList();
var lists = s.OrderBy(x => x).ToList();
int i = ;
int j = ;
int children = ;
while (i < listg.Count && j < lists.Count)
{
var greed = listg[i];
var cookie = lists[j];
if (greed > cookie)
{
j++;
}
else
{
//greed<=cookie
children++;
i++;
j++;
}
}
Console.WriteLine(children);
return children;
}
}
https://leetcode.com/problems/assign-cookies/#/description
leetcode455的更多相关文章
- [Swift]LeetCode455. 分发饼干 | Assign Cookies
Assume you are an awesome parent and want to give your children some cookies. But, you should give e ...
- LeetCode455. Assign Cookies
Description Assume you are an awesome parent and want to give your children some cookies. But, you s ...
- Leetcode455.Assign Cookies分发饼干
假设你是一位很棒的家长,想要给你的孩子们一些小饼干.但是,每个孩子最多只能给一块饼干.对每个孩子 i ,都有一个胃口值 gi ,这是能让孩子们满足胃口的饼干的最小尺寸:并且每块饼干 j ,都有一个尺寸 ...
- LeetCode455 分发饼干(简单贪心—Java优先队列简单应用)
题目: 假设你是一位很棒的家长,想要给你的孩子们一些小饼干.但是,每个孩子最多只能给一块饼干.对每个孩子 i ,都有一个胃口值 gi ,这是能让孩子们满足胃口的饼干的最小尺寸:并且每块饼干 j ,都有 ...
随机推荐
- Hibernate有五大核心接口,分别是:Session Transaction Query SessionFactoryConfiguration
Session接口: Session接口 Session 接口对于Hibernate 开发人员来说是一个最重要的接口.然而在Hibernate中,实例化的Session是一个轻量级的类,创建和销毁它都 ...
- 一 JAVA整体概念以及安装部署
JAVA 基本概念 JVM(JAVA virtual machine)java虚拟机,是java的能跨平台的核心,java的跨平台实现,就是在各种系统中布置JVM,然后java应用运行在JVM中,相 ...
- 【转】每天一个linux命令(21):find命令之xargs
原文网址:http://www.cnblogs.com/peida/archive/2012/11/15/2770888.html 在使用 find命令的-exec选项处理匹配到的文件时, find命 ...
- GitLab 502问题的解决
问题: 502 Whoops, GitLab is taking too much time to respond. 日志: [root@cs12-66-gitlab ~]# my gitlab-ct ...
- JWT 基础教程
原文地址:JWT 基础教程 博客地址:http://www.extlight.com 一.前言 针对前后端分离的项目,大多是通过 token 进行身份认证来进行交互,今天将介绍一种简单的创建 toke ...
- Web自动化测试框架Watir(基于Ruby) - 第2章 使用Watir写自动化测试脚本
一.先来看一个小DEMO 通过上一篇博文<Web自动化测试框架Watir(基于Ruby) - 第1章 Windows下安装与部署>的介绍,我们已经有了完整Watir运行环境,现在我们可以来 ...
- AngularJs $scope 里面的$apply 方法和$watch方法
Angular $scope 里面的$apply 方法 Scope提供$apply方法传播Model变化 <!DOCTYPE html> <html> <head> ...
- IE 10 如何设置支持CRM4 正常浏览
通过工具—> 选择兼容性视图 就可以了.具体如下图:
- Densenet 相关
https://github.com/flyyufelix/DenseNet-Keras
- win7 X64 使用VS2008 ->编译报错LINK : fatal error LNK1000: Internal error during Incr的解决
编译报错LINK : fatal error LNK1000: Internal error during Incr的解决 Win7 旗舰版 Microsoft Visual Studio 2008 ...