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
}
相关推荐
菜菜的顾清寒4 分钟前
力扣HOT100(51) 动态规划-单词拆分
算法·leetcode·动态规划
l齐天5 分钟前
Ubuntu 22.04 环境下 PBC 与 Golang 的安装、配置与测试
linux·ubuntu·golang
codeejun9 分钟前
每日一 Go-72、分布式事务 & 一致性:本地消息表、事务消息、SAGA、TCC怎么选?
开发语言·分布式·golang
cpp_250126 分钟前
P10109 [GESP202312 六级] 工作沟通
数据结构·c++·算法·题解·洛谷·gesp六级
ʚ希希ɞ ྀ30 分钟前
全排列 --- 回溯
算法·leetcode·深度优先
8Qi837 分钟前
LeetCode 124. 二叉树中的最大路径和(Hard)
算法·leetcode·二叉树·递归
And_Ii41 分钟前
LeetCode 1. 两数之和 python
数据结构·算法·leetcode
cpp_25011 小时前
P10377 [GESP202403 六级] 好斗的牛
数据结构·c++·算法·题解·洛谷·gesp六级
Navigator_Z8 小时前
LeetCode //C - 1089. Duplicate Zeros
c语言·算法·leetcode
语戚12 小时前
力扣 3161. 块放置查询:线段树解法(Java 实现)
java·算法·leetcode·面试·线段树·力扣·