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

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
相关推荐
前端 贾公子9 小时前
LangGraph == 图的状态(State)管理 (中)
开发语言·数据库·python
Interview Aid1129 小时前
Stripe VO 面经汇总:5 轮面试题目与考察重点
算法
EEET智选10 小时前
科技晨间速报 | AI 安全警钟、开源新模型与苹果智能家居
人工智能·科技·算法·机器学习·ai
挖掘狂人10 小时前
哈希算法:一根看不见的 "指纹",如何撑起整个互联网
算法·程序员·掘金技术征文
the局外人10 小时前
FastAPI中jwt的基本使用与实践
后端·python·fastapi
鶴哥只手遮天10 小时前
ecRad 1.5.0 算法原理详解
算法·开源
mklpo14710 小时前
为不支持sse4.2命令集的老旧设备制作Win11 26H2系统镜像,2026-10-11。
运维·windows·python
GoldenSpider.AI10 小时前
用 AI 改流程之前先做「四桶」体检:9 次返工里 8 次靠规则就能消掉(附 Python 发布前校验器)
人工智能·python·自动化·ai智能体
小白快快跑哦10 小时前
python-字符串全解(六):正则表达式-修饰符
python·正则表达式·修饰符
不会就选b10 小时前
算法日常・每日刷题--<动态规划>22
算法·动态规划