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
}
相关推荐
吞下星星的少年·-·15 小时前
LeetCode 热题 100 最长连续序列(哈希表)
算法·leetcode·散列表
Pniubi16 小时前
力扣25.K个一组反转链表
算法·leetcode·链表
sunly_17 小时前
Go 切片详解
开发语言·oracle·golang
小白的高手之路17 小时前
【LeetCode 热题 100】560. 和为 K 的子数组|前缀和、哈希表(Python)
数据结构·笔记·python·算法·leetcode·力扣·散列表
利威尔xu20 小时前
Go interface 底层:空接口装任何东西,类型断言漏写 ok 直接 panic 拖垮服务
开发语言·golang·interface·类型断言·itab
Zenova EdgeOS20 小时前
Go Redis 实战:工业边缘场景下的 go-redis
数据库·redis·golang·边缘计算·工业网关
劲夫学编程1 天前
leetcode: 字母异位词分组
算法·leetcode
wy_hhxx1 天前
[Leetcode] 动态规划(打家劫舍、0-1背包、完全背包)
算法·leetcode·动态规划·完全背包·0-1背包
Shaoshing1 天前
LeetCode100 32.最长有效括号
java·数据结构·leetcode
小白的高手之路1 天前
【LeetCode 热题 100】240. 搜索二维矩阵 II|矩阵、二分查找、Z 字形查找(Python)
python·算法·leetcode·矩阵·力扣