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
}
相关推荐
xcLeigh7 小时前
Go入门:变量声明的五种方式详解
java·开发语言·golang
皓月斯语10 小时前
B2118 验证子串
c++·题解
Hi李耶11 小时前
【LeetCode】4-寻找两个正序数组的中位数
算法·leetcode·职场和发展
Hi李耶14 小时前
【LeetCode】6-Z字形变换
算法·leetcode·职场和发展
AKA__Zas15 小时前
芝士算法(前缀和2.0)
java·数据结构·算法·leetcode·哈希算法·学习方法
皓月斯语15 小时前
B3867 [GESP202309 三级] 小杨的储蓄 题解
c++·算法·题解
techdashen15 小时前
Go设计取舍之三: 0.3ns每次的错误Benchmark
开发语言·后端·golang
XWalnut15 小时前
LeetCode刷题 day33
java·数据结构·算法·leetcode
闪电悠米16 小时前
力扣hot100-142.环形链表II-哈希集合与快慢指针详解
leetcode·链表·哈希算法
Tisfy16 小时前
LeetCode 0486.预测赢家:深度优先搜索(DFS)
算法·leetcode·深度优先·dfs·博弈