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
}
相关推荐
阿Y加油吧10 分钟前
二刷 LeetCode:两道经典贪心题复盘
算法·leetcode·职场和发展
Java成神之路-13 分钟前
【LeetCode 刷题笔记】35. 搜索插入位置 | 二分查找经典入门题
算法·leetcode
geovindu6 小时前
go: Mediator Pattern
设计模式·golang·中介者模式
Navigator_Z11 小时前
LeetCode //C - 1033. Moving Stones Until Consecutive
c语言·算法·leetcode
We་ct17 小时前
LeetCode 72. 编辑距离:动态规划经典题解
前端·算法·leetcode·typescript·动态规划
m0_6294947318 小时前
LeetCode 热题 100-----17.缺失的第一个正数
数据结构·算法·leetcode
Tisfy18 小时前
LeetCode 0796.旋转字符串:暴力模拟
算法·leetcode·题解·模拟·字符串匹配
小雅痞19 小时前
[Java][Leetcode middle] 209. 长度最小的子数组
java·算法·leetcode
浅念-1 天前
吃透栈:LeetCode 栈算法题全解析
数据结构·c++·算法·leetcode·职场和发展·
阿Y加油吧1 天前
二刷 LeetCode:62. 不同路径 & 64. 最小路径和 复盘笔记
笔记·算法·leetcode