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;
}
相关推荐
菜鸟233号1 小时前
力扣213 打家劫舍II java实现
java·数据结构·算法·leetcode
方便面不加香菜1 小时前
数据结构--栈和队列
c语言·数据结构
狐571 小时前
2026-01-18-LeetCode刷题笔记-1895-最大的幻方
笔记·算法·leetcode
Q741_1471 小时前
C++ 队列 宽度优先搜索 BFS 力扣 662. 二叉树最大宽度 每日一题
c++·算法·leetcode·bfs·宽度优先
踩坑记录2 小时前
leetcode hot100 54.螺旋矩阵 medium
leetcode
王老师青少年编程2 小时前
2024年3月GESP真题及题解(C++七级): 俄罗斯方块
c++·题解·真题·gesp·csp·俄罗斯方块·七级
切糕师学AI2 小时前
ARM 中的 SVC 监管调用(Supervisor Call)
linux·c语言·汇编·arm开发
移幻漂流3 小时前
C/C++并发编程详解:如何写出优秀的并发程序
c语言·开发语言·c++
Jia shuheng4 小时前
#ifdef __cplusplus extern “C“ #endif的作用
c语言·嵌入式硬件
源代码•宸4 小时前
Leetcode—3. 无重复字符的最长子串【中等】
经验分享·后端·算法·leetcode·面试·golang·string