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
}
相关推荐
Forever Nore2 小时前
LeetCode 6 Z 字形变换 - 按行模拟
算法·leetcode
wabs6663 小时前
关于哈希表【力扣383.赎金信的思考】
算法·leetcode·散列表
ttwuai3 小时前
Go 后台定时任务启停不生效怎么办?先查调度同步链路
开发语言·后端·golang
运维开发笔记3 小时前
3.1 Go if 语句学习笔记
golang
.道阻且长.12 小时前
2.LeetCode算法习题讲解--双指针--复写零
算法·leetcode·职场和发展
To_OC14 小时前
LC 438 找到所有字母异位词:暴力超时后,我靠滑动窗口一招搞定
javascript·算法·leetcode
Tisfy19 小时前
LeetCode 3731.找出缺失的元素:哈希 / 排序
算法·leetcode·哈希算法·排序·哈希表
旖旎夜光20 小时前
LeetCode 11:盛最多水的容器(双指针问题) —— 题解
数据结构·c++·算法·leetcode·双指针
一只齐刘海的猫20 小时前
【Leetcode】乘积最大子数组
算法·leetcode·职场和发展
hold?fish:palm1 天前
20 旋转图像
c++·算法·leetcode