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

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
相关推荐
LK_0737 分钟前
【力扣】142. 环形链表 II |Python
python·leetcode·链表
wuyk55537 分钟前
Python办公自动化-第02讲-Excel文件认知与四大库选型
开发语言·python·excel
Pniubi1 小时前
力扣21合并两个有序链表
算法·leetcode·职场和发展
AIgorithmGEEK1 小时前
std::unordered_map 与 std::unordered_set:接口、算法技巧与权衡 (速查)
c++·算法·哈希表·负载因子·桶·unordered_map·unordered_set
用户54817845909502 小时前
Java 与 Python 在大模型与智能体领域的选型
java·python
文丑颜不良啊2 小时前
LeetCode3341~3360题目解析
java·leetcode
yiangL_2 小时前
1、Python 输入输出实验|print 与 input 人机交互实践
开发语言·python·人机交互
上海潭龙东海科技有限公司3 小时前
智慧堆场动态模型三维实时孪生重构智能管控
大数据·网络·数据库·算法·重构
高洁013 小时前
世界模型的因果内核:从预测表象到理解机制
人工智能·python·深度学习·transformer·迁移学习