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
}
相关推荐
退休倒计时3 小时前
【每日一题】LeetCode 53. 最大子数组和 TypeScript
数据结构·算法·leetcode·typescript
张忠琳4 小时前
【Go 1.26.4】Golang Channel 深度解析
开发语言·后端·golang
洛水水5 小时前
【力扣100题】86.柱状图中最大的矩形
算法·leetcode·职场和发展
洛水水7 小时前
【力扣100题】81.寻找两个正序数组的中位数
数据结构·算法·leetcode
张忠琳7 小时前
【Go 1.26.4】Golang Map 深度解析
开发语言·后端·golang
洛水水7 小时前
【力扣100题】85.每日温度
算法·leetcode·职场和发展
Kurisu_红莉栖8 小时前
力扣56合并区间
算法·leetcode
开源Z8 小时前
LeetCode 135 · 分发糖果:两次扫描,先左后右取最大
算法·leetcode
退休倒计时8 小时前
【每日一题】LeetCode 19. 删除链表的倒数第 N 个结点 TypeScript
leetcode·链表·typescript
怪兽学LLM11 小时前
LeetCode 21 合并两个有序链表:彻底理解虚拟头节点(Dummy)套路
python·leetcode·链表