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;
}
相关推荐
文丑颜不良啊1 小时前
LeetCode2841~2860题目解析
java·leetcode
文丑颜不良啊3 小时前
LeetCode2921~2940题目解析
java·leetcode
文丑颜不良啊5 小时前
LeetCode2901~2920题目解析
java·leetcode
文丑颜不良啊7 小时前
LeetCode2861~2880题目解析
java·leetcode
another heaven8 小时前
【C/C++ 第一次跨越(上):用 C++11/14 停止制造新的旧代码】
c语言·c++·制造
another heaven1 天前
【C/C++ Ranges 是零开销抽象吗?拆开管道、惰性求值和编译期膨胀】
c语言·开发语言·c++
Code_Solitude1 天前
C语言动态内存 + 柔性数组 + 数组名退化
c语言·算法·柔性数组
文丑颜不良啊1 天前
LeetCode2821~2840题目解析
java·leetcode
Zwawa1 天前
让屏幕动起来:OLED动画效果,丝滑光标、帧动画和一只贪吃蛇
c语言·单片机·嵌入式
Pniubi1 天前
力扣24. 两两交换链表中的节点(递归)
算法·leetcode·链表