代码随想录 -- 贪心算法 -- 分发饼干

455. 分发饼干 - 力扣(LeetCode)

python 复制代码
class Solution(object):
    def findContentChildren(self, g, s):
        num=0
        g.sort()
        s.sort()
        index=0
        for i in range(len(s)):
            while index<len(g) and s[i]>=g[index]:
                index+=1
                num+=1 
                break
        return num
相关推荐
什巳2 小时前
JAVA练习306- 翻转二叉树
java·数据结构·算法·leetcode
smj2302_796826522 小时前
解决leetcode第3989题网格中保持一致的最大列数
python·算法·leetcode
吴梓穆3 小时前
Python 基础 正则表达式
python
巧克力男孩dd3 小时前
Python超典型练习题(第一次作业)
开发语言·python·算法
爱刷碗的苏泓舒3 小时前
平方根信息滤波:矩阵推导及 GNSS 参数估计应用
线性代数·算法·矩阵·gnss·参数估计·测量平差·平方根信息滤波
闲猫4 小时前
LangChain / Core components / Models
开发语言·python·langchain
想做小南娘,发现自己是女生喵4 小时前
第 2 章 顺序表和 vector
java·数据结构·算法
艾醒5 小时前
2026年第29周(7.13-7.19)AI全复盘:技术突破、行业趣闻翻车、算力服务器商业动态
人工智能·算法
雪碧聊技术5 小时前
动态规划算法—01背包问题
算法·动态规划
bu_shuo5 小时前
c与cpp中的argc和argv
c语言·c++·算法