【leetcode】solution in java——Easy5
转载请注明原文地址:
21: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.
此题:分点心。每个小孩i期望获得g[i]块点心。你有多种不同口味的点心s[]。你只能分配一种口味的点心给一个小孩而且点心数量大于g[i]小孩i才会满意。问你最多能满足多少个小孩?
思路:对小孩的期望数组与拥有的点心数组按升序排列,从需求小的小孩开始逐个满足:针对当前需求,检索还没分配的点心数组,把第一个能满足需求的点心分给这个小孩。
【leetcode】solution in java——Easy5的更多相关文章
- 【leetcode】solution in java——Easy4
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6415011.html 16:Invert Binary Tree 此题:以根为对称轴,反转二叉树. 思路:看到 ...
- 【leetcode】solution in java——Easy3
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6412505.html 心得:看到一道题,优先往栈,队列,map,list这些工具的使用上面想.不要来去都是暴搜 ...
- 【leetcode】solution in java——Easy2
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6410409.html 6:Reverse String Write a function that takes ...
- 【leetcode】solution in java——Easy1
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6409067.html 1:Hamming distance The Hamming distance betw ...
- 【Leetcode】Reorder List JAVA
一.题目描述 Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must ...
- 【Leetcode】Sort List JAVA实现
Sort a linked list in O(n log n) time using constant space complexity. 1.分析 该题主要考查了链接上的合并排序算法. 2.正确代 ...
- 【LeetCode】Minimum Depth of Binary Tree 二叉树的最小深度 java
[LeetCode]Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum dept ...
- 【刷题】【LeetCode】007-整数反转-easy
[刷题][LeetCode]总 用动画的形式呈现解LeetCode题目的思路 参考链接-空 007-整数反转 方法: 弹出和推入数字 & 溢出前进行检查 思路: 我们可以一次构建反转整数的一位 ...
- 【LeetCode】Permutations 解题报告
全排列问题.经常使用的排列生成算法有序数法.字典序法.换位法(Johnson(Johnson-Trotter).轮转法以及Shift cursor cursor* (Gao & Wang)法. ...
随机推荐
- 超能英雄第一至四季/全集Heroes迅雷下载
本季第一.二.三.四季 Heroes Season (2006-2009) 看点:<Heroes>是NBC电视台于2006年九月开播的最新科幻电视剧.Heroes(中文剧名为“英雄”或“天 ...
- Android热修复技术总结
https://blog.csdn.net/xiangzhihong8/article/details/77718004 插件化和热修复技术是Android开发中比较高级的知识点,是中级开发人员通向高 ...
- Orchard 前台权限与自定义权限
一:关于前台权限 1:只允许自己看到 首先,我们需要确定在 Role 设置页面,用户所对应的 View Page by others 和 View all content 未被选中.备注,我们首先和得 ...
- 【Codeforces】【#295】【Div.1】
嘛,一直以来蒟蒻都没怎么打过CF……现在还是蓝名狗……今天跟着zyf打了一场virtual,果断一题滚粗
- SQL Script for select data from ebs and make a csv file to FTP
DECLARE CURSOR cur_lcy_test IS SELECT rcta.customer_trx_id, rcta.trx_number, rcta.trx_date FROM ra_c ...
- RV32C指令集
Risc-V支持16位压缩格式,压缩格式立即数位数更少,能使用的寄存器也比较少,有些指令只能用常用8个整数寄存器(x8-x15)或者(f8-f15). 每个RVC指令都有对应的32位指令,下表列出所有 ...
- hdu-4466-Triangle 数学题
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4466 题目意思: 一根长为N的木棒,长度分成若干个三角形,使得任意两个三角形都相似.对应顺序三角形全 ...
- Cesium学习笔记(七):Demo学习(自由控制飞行的飞机)[转]
https://blog.csdn.net/umgsoil/article/details/74923013# 这是官方的教程Demo,名字叫Use HeadingPitchRoll,顾名思义,就是教 ...
- AOP AspectJ 字节码 语法 MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...
- 不用IDE写C#的Hello World
用Visual Studio等IDE写C#的Hello World非常简单,但脱离了IDE你能不能打印出Hello World呢?这不是说工作时脱离IDE,而是学习一下CLR的执行模型. Hello ...