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
}
相关推荐
田梓燊3 小时前
力扣:19.删除链表的倒数第 N 个结点
算法·leetcode·链表
anzhxu5 小时前
Go基础之环境搭建
开发语言·后端·golang
ILYT NCTR8 小时前
搭建Golang gRPC环境:protoc、protoc-gen-go 和 protoc-gen-go-grpc 工具安装教程
开发语言·后端·golang
叶小鸡8 小时前
小鸡玩算法-力扣HOT100-堆
数据结构·算法·leetcode
小雅痞8 小时前
[Java][Leetcode simple] 28. 找出字符串中第一个匹配项的下标
java·开发语言·leetcode
khalil10209 小时前
代码随想录算法训练营Day-31贪心算法 | 56. 合并区间、738. 单调递增的数字、968. 监控二叉树
数据结构·c++·算法·leetcode·贪心算法·二叉树·递归
im_AMBER13 小时前
Leetcode 160 最小覆盖子串 | 串联所有单词的子串
开发语言·javascript·数据结构·算法·leetcode
帅小伙―苏14 小时前
力扣483找到字符串中所有字母异位词
算法·leetcode
smj2302_7968265215 小时前
解决leetcode第3906题统计网格路径中好整数的数目
python·算法·leetcode
KobeSacre15 小时前
leetcode 树
算法·leetcode·职场和发展