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

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
相关推荐
2501_921649493 分钟前
股指期货 API 入门指南:如何获取实时行情与构建交易系统
python·websocket·金融·区块链·restful
YGGP6 分钟前
【Golang】LeetCode 2. 两数相加
开发语言·leetcode·golang
努力学算法的蒟蒻8 分钟前
day53(1.4)——leetcode面试经典150
算法·leetcode·面试
leiming611 分钟前
c++ transform算法
开发语言·c++·算法
橘颂TA23 分钟前
【剑斩OFFER】哈希表简介
数据结构·算法·散列表
小尧嵌入式23 分钟前
c++红黑树及B树B+树
开发语言·数据结构·c++·windows·b树·算法·排序算法
optimistic_chen25 分钟前
【Redis 系列】常用数据结构---ZSET类型
数据结构·数据库·redis·xshell·zset·redis命令
Full Stack Developme26 分钟前
Spring Security 与 Apache Shiro 两大安全框架比较
spring boot·python·安全
tobias.b29 分钟前
408真题解析-2009-10-数据结构-排序
数据结构·算法·排序算法·408考研·408真题·真题解析
杰瑞哥哥31 分钟前
快速搭建Web前端(streamlit使用指南)
python·信息可视化·web·模型部署