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
相关推荐
Birdy_x20 分钟前
接口自动化项目实战(1):requests请求封装
开发语言·前端·python
我爱学习好爱好爱24 分钟前
Ansible 常用模块详解:lineinfile、replace、get_url实战
linux·python·ansible
海海不瞌睡(捏捏王子)36 分钟前
C++ 知识点概要
开发语言·c++
桌面运维家1 小时前
VLAN配置进阶:抑制广播风暴,提升网络效率
开发语言·网络·php
一轮弯弯的明月2 小时前
Python基础-速通秘籍(下)
开发语言·笔记·python·学习
西西学代码2 小时前
Flutter---回调函数
开发语言·javascript·flutter
大尚来也2 小时前
深入HashMap底层:从JDK1.7到1.8的架构演进与性能突围
开发语言
千寻girling3 小时前
面试官 : “ 说一下 Python 中的常用的 字符串和数组 的 方法有哪些 ? ”
人工智能·后端·python
森林里的程序猿猿3 小时前
并发设计模式
java·开发语言·jvm
222you3 小时前
四个主要的函数式接口
java·开发语言