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
}
相关推荐
码途行者6 小时前
每天10分钟学Go:第22课 自定义错误
开发语言·后端·golang
wy_hhxx12 小时前
[Leetcode] 滑动窗口
算法·leetcode·滑动窗口
码途行者12 小时前
每天10分钟学Go:第20课 泛型
c++·算法·golang
codeejun13 小时前
每日一Go·MySQL-20、SQL 性能调优实战总结
sql·mysql·golang
AIgorithmGEEK14 小时前
算法·哈希表|从“逐个比”到“按 key 算位置”
数据结构·c++·算法·leetcode·hash
Navigator_Z17 小时前
LeetCode //C - 1319. Number of Operations to Make Network Connected
c语言·算法·leetcode
Navigator_Z1 天前
LeetCode //C - 1318. Minimum Flips to Make a OR b Equal to c
c语言·算法·leetcode
驭渊的小故事2 天前
LeetCode 33:搜索旋转排序数组——从二分查找到旋转数组的区间判定
算法·leetcode·职场和发展
利威尔xu2 天前
Go sync.Map底层3层缓存:并发写map直接崩溃,读多写少无锁读拖垮选错锁
golang
郝学胜-神的一滴3 天前
Effective STL 条款 07:指针容器销毁前先删除
开发语言·c++·vscode·leetcode·rpc·visual studio