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
}
相关推荐
qq_452396233 小时前
第五篇:《接口与错误处理:Go 的哲学》
开发语言·后端·golang
程序猿乐锅3 小时前
【数据结构与算法 | 第六篇】力扣1109,1094差分数组
java·算法·leetcode
布朗克1685 小时前
Go 入门到精通-29-测试与基准
开发语言·后端·golang·测试与基准
hold?fish:palm7 小时前
9 找到字符串中所有字母异位词
c++·算法·leetcode
Sw1zzle7 小时前
算法入门(六):贪心算法 - 基础入门(Leetcode 121/455/860/376/738)
算法·leetcode·贪心算法
青山木8 小时前
Hot 100 --- 岛屿数量
java·数据结构·算法·leetcode·深度优先·广度优先
啦啦啦啦啦zzzz8 小时前
算法:回溯算法
c++·算法·leetcode
止语Lab11 小时前
从 PHP 到 Go:真正迁移的是复杂度的归属
android·golang·php
小肝一下11 小时前
3. 单链表
c语言·数据结构·c++·算法·leetcode·链表·dijkstra
tachibana211 小时前
hot100 前 K 个高频元素(347)
java·数据结构·算法·leetcode