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
}
相关推荐
星轨初途1 小时前
LeetCode 热题 100——day7 接雨水
数据结构·c++·笔记·算法·leetcode·职场和发展
青 春 记 忆8 小时前
LeetCode 21. 合并两个有序链表|Python 解法详解
python·算法·leetcode·链表
Forever Nore15 小时前
LeetCode 1 两数之和
算法·leetcode·职场和发展
To_OC15 小时前
LC 3 无重复字符的最长子串:从入门滑动窗口到优化写法,再也不怕面试官追问
javascript·算法·leetcode
microrain16 小时前
从监控孤岛到视联一体:SagooIoT视频监控中心的设计实践
物联网·golang·开源·sagooiot
青 春 记 忆19 小时前
LeetCode 53. 最大子数组和|Python 解法详解
python·算法·leetcode
GoFly开发者1 天前
GoFly 社区 GMQT|国产自研 MQTT‑Broker,打造私有化物联网消息底座
物联网·mqtt·golang·mqtt broker·mqtt私有化部署
退休倒计时1 天前
【每日一题】LeetCode 215. 数组中的第K个最大元素 TypeScript
算法·leetcode·typescript
刘步权1 天前
KY-RTI分布仿真技术:第十四章 Go程序设计
golang·hla·rti·高层体系结构·多语言仿真
星轨初途1 天前
LeetCode 热题 100——day6 三数之和
数据结构·c++·算法·leetcode·职场和发展