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
}
相关推荐
FfHUCisI2 小时前
Golang RESTful API 设计原则
开发语言·golang·restful
hanlin033 小时前
动态规划专练:力扣第1035、392题
算法·leetcode·动态规划
大可-4 小时前
Go Air 热重载安装配置指南
开发语言·后端·golang
evans在进步4 小时前
LeetCode 34:在排序数组中查找元素的首尾位置——Java 两次二分查找详解
java·python·leetcode
Zenova EdgeOS5 小时前
工业边缘 SDK 设计实战:从 API 到 Python/Go 多语言工程落地
python·golang·php
杨航 AI7 小时前
** AI 面试算法 50 题清单**,不是单纯的 LeetCode 题号列表,而是按照“**考察概率 × 面试价值 × 你当前准备方向**”排序
算法·leetcode·面试
.道阻且长.16 小时前
5.LeetCode算法习题讲解--双指针--有效三角形的个数
算法·leetcode·职场和发展
名字还没想好☜19 小时前
Go 的 unsafe.Pointer 实战:零拷贝 []byte↔string 转换与三条铁律
开发语言·后端·golang·go·unsafe
xin_nai19 小时前
LeetCode热题100(Java)(7)链表(下)
java·leetcode·链表
想吃火锅100520 小时前
【leetcode】54. 螺旋矩阵
算法·leetcode·矩阵