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
}
相关推荐
Navigator_Z1 小时前
LeetCode //C - 1293. Shortest Path in a Grid with Obstacles Elimination
c语言·算法·leetcode
Nil2082 小时前
leetcode 64最小路径和
算法·leetcode·职场和发展
Nil2082 小时前
leetcode 72编辑距离
算法·leetcode·职场和发展
Nil2083 小时前
leetcode 136只出现一次的数字
leetcode·哈希算法·散列表
tachibana23 小时前
Go 语言里的 Context 是什么?
开发语言·后端·golang·go·语言
lvwangshu4 小时前
川剧复演 题解
动态规划·题解·技巧·性质题·思维好题
局部有解8 小时前
LeetCode Hot100 438 找到字符串中所有字母异位词
c++·算法·leetcode
Nil2089 小时前
leetcode 75颜色分类
数据结构·算法·leetcode
茉莉玫瑰花茶10 小时前
GO [ 数据格式 ]
服务器·网络·算法·golang
aqiu11111110 小时前
CodeTop按顺序刷题0003:LeetCode 206. 反转链表(迭代法图文详解与动态演示)
算法·leetcode·链表