C语言 | Leetcode C语言题解之第452题用最少数量的箭引爆气球

题目:

题解:

cpp 复制代码
int cmp(void* _a, void* _b) {
    int *a = *(int**)_a, *b = *(int**)_b;
    return a[1] < b[1] ? -1 : 1;
}

int findMinArrowShots(int** points, int pointsSize, int* pointsColSize) {
    if (!pointsSize) {
        return 0;
    }
    qsort(points, pointsSize, sizeof(int*), cmp);
    int pos = points[0][1];
    int ans = 1;
    for (int i = 0; i < pointsSize; ++i) {
        if (points[i][0] > pos) {
            pos = points[i][1];
            ++ans;
        }
    }
    return ans;
}
相关推荐
ULTRA??1 小时前
C语言简化版本开辟动态内存的万能MALLOC宏封装
c语言·开发语言
2401_861277551 小时前
func(int* num)的实现是*num=2或者int a=3,num=&a都可以吗
c语言·c++
我要升天!1 小时前
QT -- 网络编程
c语言·开发语言·网络·c++·qt
小武~1 小时前
Leetcode 每日一题C 语言版 -- 234 basic calculator
linux·c语言·leetcode
小白程序员成长日记1 小时前
2025.12.02 力扣每日一题
数据结构·算法·leetcode
永远都不秃头的程序员(互关)2 小时前
在vscodeC语言多文件编译实战指南
c语言·数据结构·算法
吃着火锅x唱着歌2 小时前
LeetCode 3583.统计特殊三元组
算法·leetcode·职场和发展
无限进步_3 小时前
C语言宏的魔法:探索offsetof与位交换的奇妙世界
c语言·开发语言·windows·后端·算法·visual studio
代码雕刻家3 小时前
C语言关于换行符的注意事项
c语言·开发语言
狐573 小时前
2025-12-04-LeetCode刷题笔记-2211-统计道路上的碰撞次数
笔记·算法·leetcode