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
}
相关推荐
圣殿骑士-Khtangc16 小时前
Go字符串高效拼接性能对比与底层原理分析
服务器·前端·golang
旖旎夜光17 小时前
LeetCode 3:无重复字符的最长子串(滑动窗口) —— 题解
数据结构·c++·算法·leetcode·滑动窗口
Navigator_Z20 小时前
LeetCode //C - 1192. Critical Connections in a Network
c语言·算法·leetcode
rannn_11120 小时前
【力扣hot100】链表专题下|138、148、23、146
java·算法·leetcode·链表·开发
xzlAwin20 小时前
Win10安装Go语言多版本管理器g工具
开发语言·golang
hanlin0321 小时前
刷题笔记:力扣第189题-轮转数组
笔记·算法·leetcode
琥珀色糖21 小时前
leetcode hot100题(持续更新)移动零(双指针)
算法·leetcode·职场和发展·双指针·移动零
hanlin031 天前
动态规划专练:力扣第718、1143题
算法·leetcode·动态规划
FfHUCisI1 天前
Golang RESTful API 设计原则
开发语言·golang·restful
hanlin031 天前
动态规划专练:力扣第1035、392题
算法·leetcode·动态规划