860.柠檬水找零
class Solution:
def lemonadeChange(self, bills: List[int]) -> bool:
five, ten, twenty = 0, 0, 0
for bill in bills:
if bill == 5:
five += 1
elif bill == 10:
if five <= 0:
return False
five -= 1
ten += 1
elif bill == 20:
if ten > 0 and five > 0:
ten -= 1
five -= 1
twenty += 1
elif five >= 3:
five -= 3
twenty += 1
else:
return False
return True
406.根据身高重建队列
class Solution:
def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:
people.sort(key=lambda x:(-x[0], x[1]))
que = []
for i in people:
que.insert(i[1], i)
return que
452. 用最少数量的箭引爆气球
class Solution:
def findMinArrowShots(self, points: List[List[int]]) -> int:
points.sort(key=lambda x: (x[0], x[1]))
count = 1
for i in range(1, len(points)):
if points[i][0] > points[i-1][1]:
count += 1
else:
points[i][1] = min(points[i-1][1], points[i][1])
return count
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?