2026.02.11

860. 柠檬水找零

python 复制代码
class Solution:
    def lemonadeChange(self, bills: List[int]) -> bool:
        cash = [0] * 11
        for i in range(len(bills)):
            if bills[i] == 5:
                cash[5] += 1
            elif bills[i] == 10:
                cash[5] -= 1
                if cash[5] < 0:
                    return False
                cash[10] += 1
            else:
                if cash[10] > 0 and cash[5] > 0:
                    cash[10] -= 1
                    cash[5] -= 1
                elif cash[5] >= 3:
                    cash[5] -= 3
                else:
                    return False
        return True

406. 根据身高重建队列

python 复制代码
class Solution:
    def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:
        people.sort(key = lambda x: (-x[0], x[1]))

        que = []
        for p in people:
            que.insert(p[1], p)
        return que

452. 用最少数量的箭引爆气球

python 复制代码
class Solution:
    def findMinArrowShots(self, points: List[List[int]]) -> int:
        points.sort(key = lambda x : x[1])
        count = 0
        ed = float('-inf')
        for p in points:
            if ed < p[0]:
                count += 1
                ed = p[1]
                
        return count
相关推荐
yong99901 分钟前
MATLAB读取高光谱图像
开发语言·matlab
2zcode6 分钟前
基于MATLAB的肝病风险评估与分期分析系统设计与实现
开发语言·matlab
小小de风呀16 分钟前
de风——【从零开始学C++】(五):内存管理
开发语言·c++
ooseabiscuit20 分钟前
Laravel6.x核心优化与特性全解析
android·开发语言·javascript
折哥的程序人生 · 物流技术专研21 分钟前
Java面试85题图解版(一):基础核心篇
java·开发语言·后端·面试
AllData公司负责人37 分钟前
通过Postgresql同步到Doris,全视角演示AllData数据中台核心功能效果,涵盖:数据入湖仓,数据同步,数据处理,数据服务,BI可视化驾驶舱
java·大数据·数据库·数据仓库·人工智能·python·postgresql
Hello.Reader1 小时前
算法基础(十)——分治思想把大问题拆成小问题
java·开发语言·算法
一只大袋鼠1 小时前
JavaWeb四种文件上传方式(下篇)
java·开发语言·springmvc·javaweb
TE-茶叶蛋2 小时前
深入研究 yudao-framework 模块:Java 编程能力提升指南
java·开发语言
Flittly2 小时前
【LangGraph新手村系列】(5)时间旅行:浏览历史、分叉时间线与修改过去
python·langchain