前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Leetcode 452. Minimum Number of Arrows to Burst Balloons

Leetcode 452. Minimum Number of Arrows to Burst Balloons

作者头像
Tyan
发布于 2021-02-04 02:49:15
发布于 2021-02-04 02:49:15
26600
代码可运行
举报
文章被收录于专栏:SnailTyanSnailTyan
运行总次数:0
代码可运行

文章作者:Tyan 博客:noahsnail.com | CSDN | 简书

1. Description

2. Solution

  • Version 1
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
class Solution:
    def findMinArrowShots(self, points):
        if len(points) == 0:
            return 0
        points.sort(key=lambda p: p[0])
        total = 1
        overlap = points[0]
        for point in points:
            if overlap[1] < point[0]:
                total += 1
                overlap = point
            else:
                overlap[0] = point[0]
                overlap[1] = min(overlap[1], point[1])

        return total
  • Version 2
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
class Solution:
    def findMinArrowShots(self, points):
        if len(points) == 0:
            return 0
        points.sort(key=lambda p: p[1])
        total = 1
        overlap = points[0]
        for point in points:
            if overlap[1] < point[0]:
                total += 1
                overlap = point

        return total

Reference

  1. https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021/02/01 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
leetcode每日一题:452. 用最少数量的箭引爆气球
题目:https://leetcode-cn.com/problems/minimum-number-of-arrows-to-burst-balloons/
用户3578099
2020/11/30
6860
leetcode每日一题:452. 用最少数量的箭引爆气球
Leetcode 435. Non-overlapping Intervals
文章作者:Tyan 博客:noahsnail.com | CSDN | 简书
Tyan
2021/02/04
2600
Leetcode 1509. Minimum Difference Between Largest and Smallest Value in Three Moves
文章作者:Tyan 博客:noahsnail.com | CSDN | 简书
Tyan
2021/08/06
3190
Leetcode 1658. Minimum Operations to Reduce X to Zero
文章作者:Tyan 博客:noahsnail.com | CSDN | 简书
Tyan
2021/09/06
4620
Leetcode 1413. Minimum Value to Get Positive Step by Step Sum
文章作者:Tyan 博客:noahsnail.com | CSDN | 简书
Tyan
2021/03/02
3910
Leetcode 1413. Minimum Value to Get Positive Step by Step Sum
Leetcode 939. Minimum Area Rectangle
文章作者:Tyan 博客:noahsnail.com | CSDN | 简书
Tyan
2021/03/02
3090
Leetcode 939. Minimum Area Rectangle
Leetcode 1937. Maximum Number of Points with Cost
文章作者:Tyan 博客:noahsnail.com | CSDN | 简书
Tyan
2021/08/06
5220
Leetcode 1785. Minimum Elements to Add to Form a Given Sum
文章作者:Tyan 博客:noahsnail.com | CSDN | 简书
Tyan
2021/08/06
2160
Leetcode 1561. Maximum Number of Coins You Can Get
文章作者:Tyan 博客:noahsnail.com | CSDN | 简书
Tyan
2021/08/10
3320
Leetcode 646. Maximum Length of Pair Chain
文章作者:Tyan 博客:noahsnail.com | CSDN | 简书
Tyan
2021/08/06
2410
Leetcode 1671. Minimum Number of Removals to Make Mountain Array
文章作者:Tyan 博客:noahsnail.com | CSDN | 简书
Tyan
2021/09/06
3180
Leetcode 1481. Least Number of Unique Integers after K Removals
文章作者:Tyan 博客:noahsnail.com | CSDN | 简书
Tyan
2021/03/02
3200
Leetcode 1481. Least Number of Unique Integers after K Removals
Leetcode 1356. Sort Integers by The Number of 1 Bits
文章作者:Tyan 博客:noahsnail.com | CSDN | 简书
Tyan
2021/07/08
4270
Leetcode 209. Minimum Size Subarray Sum
版权声明:博客文章都是作者辛苦整理的,转载请注明出处,谢谢! https://blog.csdn.net/Quincuntial/article/details/84980915
Tyan
2019/05/26
3300
Leetcode 2016. Maximum Difference Between Increasing Elements
文章作者:Tyan 博客:noahsnail.com  |  CSDN  |  简书
Tyan
2022/05/10
2420
Leetcode 2016. Maximum Difference Between Increasing Elements
Leetcode 53. Maximum Subarray
文章作者:Tyan 博客:noahsnail.com  |  CSDN  |  简书
Tyan
2022/05/09
3210
Leetcode 53. Maximum Subarray
LeetCode 452. 用最少数量的箭打破气球(贪心)
在二维空间中有许多球形的气球。对于每个气球,提供的输入是水平方向上,气球直径的开始和结束坐标。 由于它是水平的,所以y坐标并不重要,因此只要知道开始和结束的x坐标就足够了。 开始坐标总是小于结束坐标。平面内最多存在104个气球。
Michael阿明
2020/07/13
6440
Leetcode 1408. String Matching in an Array
文章作者:Tyan 博客:noahsnail.com | CSDN | 简书
Tyan
2021/07/01
2810
Leetcode 111. Minimum Depth of Binary Tree
版权声明:博客文章都是作者辛苦整理的,转载请注明出处,谢谢! https://blog.csdn.net/Quincuntial/article/details/82762706
Tyan
2019/05/25
3500
Leetcode 153. Find Minimum in Rotated Sorted Array
版权声明:博客文章都是作者辛苦整理的,转载请注明出处,谢谢! https://blog.csdn.net/Quincuntial/article/details/81568317
Tyan
2019/05/25
4060
推荐阅读
相关推荐
leetcode每日一题:452. 用最少数量的箭引爆气球
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验