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
相关推荐
维吉斯蔡2 小时前
【VS Code / Cursor】文件夹右键快捷打开与文件类型自动关联
开发语言·程序人生·学习方法
幻影123!2 小时前
从零训练一个会下五子棋的AI
python·深度学习·神经网络·强化学习·五子棋·alpha zero·mokugo
Python私教3 小时前
Django 接入 AI 大模型实战:从零做一个流式聊天网站
人工智能·python·django
Python私教3 小时前
Django 接入 MCP 实战:让 AI 安全调用数据库和业务接口
人工智能·python·django
Python私教3 小时前
Django 搭建 AI 本地知识库:文档上传、向量检索与智能问答
人工智能·python·django
luj_17684 小时前
星火科技助力边远地区防病攻坚
c语言·开发语言·c++·经验分享·算法
always_TT4 小时前
【Python 日志记录:logging 模块入门】
开发语言·python·php
xcLeigh4 小时前
Go入门:变量声明的五种方式详解
java·开发语言·golang
zmzb01034 小时前
C++课后习题训练记录Day175
开发语言·c++
脱胎换骨-军哥5 小时前
C++ 代码规范与格式化指南
开发语言·c++·代码规范