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
}
相关推荐
find1star3 小时前
LeetCode 141:环形链表
java·算法·leetcode·链表
LB21123 小时前
力扣160 21 86
算法·leetcode·职场和发展
王的宝库3 小时前
Go 项目结构:从单文件到标准工程布局
开发语言·后端·golang
花酒锄作田4 小时前
Go - Gin中使用sessions
golang
a187927218314 小时前
【算法】动态规划第二篇:双序列 DP 三课——继承、计步与断链
算法·leetcode·动态规划·dp·回溯·暴力·算法讲解
不甘先生9 小时前
Go 中 type、方法与指针接收者:从 str_name.Name() 看懂 Go 的类型系统
开发语言·后端·golang
Nil20810 小时前
leetcode 994腐烂的橘子
算法·leetcode·职场和发展
血小板要健康13 小时前
队列 + 宽搜(BFS):二叉树层序遍历 算法总结
java·数据结构·笔记·算法·leetcode·宽度优先
Casbin开源社区13 小时前
一个面板管住 29 个 AI 编程 Agent:Casbin Gateway 的配置统一、协议互转、用量统计与权限管控
人工智能·golang·开源·gateway·casbin
不会就选b14 小时前
算法日常・每日刷题--<贪心>3
数据结构·算法·leetcode