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
}
相关推荐
叶小鸡7 小时前
小鸡玩算法-力扣HOT100-多维动态规划
算法·leetcode·动态规划
菜菜的顾清寒8 小时前
力扣HOT100(42)链表-随机链表的复制
算法·leetcode·链表
OxyTheCrack9 小时前
【Golang】简述make与new内置函数以及两者的区别
开发语言·golang
菜菜的顾清寒10 小时前
HOT力扣100(43)二叉树-翻转二叉树
数据结构·算法·leetcode
朔北之忘 Clancy11 小时前
2026 年 3 月青少年软编等考 C/C++ 一级真题解析
c语言·开发语言·c++·青少年编程·题解·考级
会编程的土豆12 小时前
Go 方法接收者超清晰笔记(类型名 vs 变量名)
开发语言·笔记·golang
csdn_aspnet12 小时前
javascript 算法 LeetCode 编号 70 - 爬楼梯
开发语言·javascript·算法·leetcode·ecmascript
Navigator_Z12 小时前
LeetCode //C - 1073. Adding Two Negabinary Numbers
c语言·算法·leetcode
csdn_aspnet13 小时前
PHP 算法 LeetCode 编号 70 - 爬楼梯
算法·leetcode·php
x_xbx13 小时前
LeetCode:5. 最长回文子串
算法·leetcode·职场和发展