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

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
相关推荐
朝朝辞暮i6 小时前
C++ 第 39 章: 阶段性总复习——类、对象、构造、继承、this、指针与智能指针
开发语言·c++·算法·ros2
垆边人似月.6 小时前
华为题:污染水域
算法
All for pursuit.6 小时前
【回溯-6】79.单词搜索
数据结构·c++·算法·leetcode
ZhangJun957 小时前
Mobike 共享单车分析项目
人工智能·python·算法·kmeans·聚类·knn
XLYcmy7 小时前
PDF 论文处理器 — 优势与功能文档
大数据·python·网络安全·pdf·dify·rag·漏洞检测
Navigator_Z7 小时前
LeetCode //C - 1281. Subtract the Product and Sum of Digits of an Integer
c语言·算法·leetcode
小猴子爱上树7 小时前
跨马翻译:批量图片翻译+视频字幕+智能抠图,跨境电商在线图片翻译工具
大数据·人工智能·python·音视频
薛定e的猫咪7 小时前
(AISTATS 2023)BaCaDI 逐章阅读
人工智能·深度学习·算法·机器学习
winfredzhang7 小时前
用 Python 手写一个“所见即所得“的图片水印工具:wxPython + Pillow 实战详解
python·pillow·rotate·crop·身份改水印
Benny_Tang7 小时前
AT_arc180_d [ARC180D] Division into 3 题解
数据结构·c++·算法