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
}
相关推荐
0+1114 小时前
算法 --栈
算法·leetcode
圣保罗的大教堂4 小时前
leetcode 3723. 数位平方和的最大值 中等
leetcode
浅念-6 小时前
动态规划:线性DP——多状态DP与子数组专题笔记
c++·笔记·算法·leetcode·职场和发展·动态规划·力扣
紫洋葱hh7 小时前
Go 入门基础:类型、变量与运算符
开发语言·后端·ai·golang
学电子她就能回来吗7 小时前
LeetCode Hot 100|滑动窗口专题零基础学习笔记
笔记·学习·leetcode
拾饵9428 小时前
面试回答整理(Q1–Q3)
leetcode
codeejun8 小时前
每日一Go·MySQL-7、MySQL 核心原理全景图谱
开发语言·mysql·golang
虚无的纽扣8 小时前
【力扣刷题】第四天:三数之和、四数之和
算法·leetcode·职场和发展
_不会dp不改名_9 小时前
leetcode_3273 数位平方和的最大值
算法·leetcode·职场和发展
acd120099 小时前
Go 里 err 被不经意覆盖的几个现场
开发语言·后端·golang