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 小时前
每日一题:LeetCode 3:无重复字符的最长子串——滑动窗口思路详解
算法·leetcode·职场和发展
无忧.芙桃4 小时前
C++ 并查集详解:原理、实现与应用
c语言·c++·算法·leetcode
蛋蛋的就会顺顺的4 小时前
hot100——二叉树
java·数据结构·算法·leetcode·力扣
Nil2087 小时前
leetcode 55跳跃游戏
算法·leetcode·游戏
longlongzihan7 小时前
LeetCode 128. 最长连续序列 —— 从排序到哈希集合
数据结构·c++·算法·leetcode·排序算法·哈希表
谢亮_vipxieliang7 小时前
Go defer、panic与recover核心知识点
开发语言·后端·golang
谢亮_vipxieliang8 小时前
Go基础数据类型全解
开发语言·后端·golang
圣保罗的大教堂9 小时前
leetcode 3302. 字典序最小的合法序列 中等
leetcode
谢亮_vipxieliang9 小时前
Go 接口设计原则核心知识点
开发语言·ios·golang
谢亮_vipxieliang9 小时前
Go 结构体与方法集核心知识点
java·开发语言·golang