7 Star 34 Fork 23

空無一悟/algorithms

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Solution.java 811 Bytes
一键复制 编辑 原始数据 按行查看 历史
空無一悟 提交于 2021-09-22 23:47 +08:00 . init
/***********************************************************
* @Description :
* @author : 梁山广(Liang Shan Guang)
* @date : 2020/1/27 23:33
* @email : liangshanguang2@gmail.com
***********************************************************/
package Chapter10GreedyAlgorithms.Section01AssignCookies.LeetCode455分发饼干;
import java.util.Arrays;
class Solution {
public int findContentChildren(int[] g, int[] s) {
Arrays.sort(g);
Arrays.sort(s);
int gi = g.length - 1;
int si = s.length - 1;
int res = 0;
while (gi >= 0 && si >= 0) {
if (s[si] >= g[gi]) {
si--;
gi--;
res++;
} else {
gi--;
}
}
return res;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lsgwr/algorithms.git
git@gitee.com:lsgwr/algorithms.git
lsgwr
algorithms
algorithms
master

搜索帮助