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 算法题解:滑动窗口与数组合并的实战应用
算法·leetcode·职场和发展
文丑颜不良啊1 小时前
LeetCode1501~1520题目解析
java·leetcode
microrain2 小时前
跟着一条属性报文走一遍 SagooIoT 的接入链路
物联网·架构·golang·sagooiot
CodeGL2 小时前
微服务框架——go-zero
微服务·架构·golang
Navigator_Z2 小时前
LeetCode //C - 1311. Get Watched Videos by Your Friends
c语言·算法·leetcode
Pniubi3 小时前
力扣42接雨水(动态规划法)
算法·leetcode·职场和发展
Pniubi4 小时前
力扣46全排列(回溯(递归))
算法·leetcode·职场和发展
文丑颜不良啊5 小时前
LeetCode1461~1480题目解析
java·leetcode
Pniubi14 小时前
力扣283移动零(双指针法)
算法·leetcode·职场和发展
旖旎夜光1 天前
LeetCode 315: 算右侧小于当前元素的个数(归并排序) —— 题解
c++·学习·算法·leetcode·排序算法