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

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
相关推荐
青 春 记 忆7 小时前
零基础入门python70:Docker Compose 编排完整后端
python·后端开发
新时代牛马7 小时前
字符设备驱动完整篇:从 cdev_add、file_operations 到chrdev_open 与排障
开发语言·python
政企项目老覃7 小时前
大模型幻觉治理与自动评测:金融风控场景的落地实践
人工智能·算法·机器学习
淡海水8 小时前
08-03-不可变-ImmutableDictionary-TKey-TValue-与ImmutableHashSet-T-持久化哈希树
数据结构·算法·c#·哈希算法·dictionary·immutable
白山编程大哥8 小时前
Java OutputStreamWriter 详解:从字符到字节的桥梁
java·开发语言·python
hansang_IR8 小时前
【题解】[APIO2023] 赛博乐园 / cyberland
c++·算法·图论
洛阳纸贵8 小时前
MATLAB-matlab基础知识
学习·算法·matlab
落羽的落羽8 小时前
【AI】快速理解AI应用的相关名词概念
linux·c++·人工智能·python·计算机网络·算法
Chasing__Dreams8 小时前
大模型应用开发--13--RAG 查询优化策略
python