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
相关推荐
星空椰8 小时前
Python 面向对象高级:继承与类定义详解
开发语言·python
白露与泡影8 小时前
2026大厂Java面试题大全!牛客网最新版
java·开发语言
凯瑟琳.奥古斯特8 小时前
高阶子查询题目精炼
开发语言·数据库·python·职场和发展·数据库开发
风之所往_8 小时前
Python 3.4 新特性全面总结
python
雪度娃娃8 小时前
转向现代C++——在意为改写的函数添加 override
开发语言·c++
太阳上的雨天9 小时前
任何格式的文件转Markdown
python·ai
yaoxin5211239 小时前
419. 现代 Java IO 最佳实践 - 写入文本文件
java·windows·python
喵星人工作室9 小时前
C++火影忍者1.1.2
开发语言·c++
weixin_4684668510 小时前
纳米 AI 搜索新手极速上手指南
人工智能·python·深度学习·搜索引擎·ai·语言模型·自然语言处理
凯瑟琳.奥古斯特10 小时前
数据库原理选择题精选
数据库·python·职场和发展