Golang | Leetcode Golang题解之第452题用最少数量的箭引爆气球

题目:

题解:

Go 复制代码
func findMinArrowShots(points [][]int) int {
    if len(points) == 0 {
        return 0
    }
    sort.Slice(points, func(i, j int) bool { return points[i][1] < points[j][1] })
    maxRight := points[0][1]
    ans := 1
    for _, p := range points {
        if p[0] > maxRight {
            maxRight = p[1]
            ans++
        }
    }
    return ans
}
相关推荐
什巳14 小时前
JAVA练习278- 和为 K 的子数组
java·学习·算法·leetcode
鱼儿也有烦恼16 小时前
快速学完 LeetCode top 1~50
leetcode·algorithm
李燚20 小时前
Eino devops 调试系统源码:GraphCompileCallback 怎么工作(第50篇-E36)
数据库·golang·agent·devops·graphql·aiagent·eino
退休倒计时20 小时前
【每日一题】LeetCode 17. 电话号码的字母组合 TypeScript
算法·leetcode·typescript
临沂堇1 天前
刷题日志 | LeetCode Hot 100 双指针
算法·leetcode·职场和发展
XWalnut1 天前
LeetCode刷题 day29
java·算法·leetcode
名字还没想好☜1 天前
Go 内存逃逸分析:什么时候变量跑到堆上
开发语言·算法·性能优化·golang·go·内存逃逸
小欣加油1 天前
leetcode1331 数组序号转换
数据结构·c++·算法·leetcode·职场和发展
ttwuai1 天前
后台管理系统 RBAC 排障:隐藏菜单后接口为什么还能调用
golang
Hesionberger1 天前
动态规划与二分法破解最长递增子序列
java·数据结构·python·算法·leetcode