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
}
相关推荐
hanlin032 小时前
刷题笔记:力扣第287题-寻找重复数
笔记·算法·leetcode
橘子汽水1682 小时前
Leetcode 322 279 零钱兑换,完全平方数
算法·leetcode
土司大王3 小时前
LeetCode hot100——51.N 皇后:Java 回溯模板、列与对角线剪枝、O(n!) 复杂度分析
java·leetcode·剪枝
金金计较.3 小时前
Go语言-2
开发语言·算法·golang
木井巳4 小时前
【记忆化搜索】斐波那契数
java·算法·leetcode·深度优先·剪枝·推荐算法
平头哥AI15 小时前
Day 22 _ 包装错误别丢链_%w、errors.Is 与 errors.As
android·服务器·学习·golang·go
Navigator_Z19 小时前
LeetCode //C - 1240. Tiling a Rectangle with the Fewest Squares
c语言·算法·leetcode
稻米哟19 小时前
力扣100——双指针
算法·leetcode
golang学习记19 小时前
Go 1.27新特性: json/v2使用有趣指南
开发语言·golang·json
王码码203521 小时前
Go语言CGO:Go与C交互
后端·golang·go·接口