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;
}
相关推荐
梁下轻语的秋缘8 小时前
每日c/c++题 备战蓝桥杯(P1049 [NOIP 2001 普及组] 装箱问题)
c语言·c++·学习·蓝桥杯
加点油。。。。8 小时前
C语言高频面试题——指针函数和函数指针的区别
c语言·面试
Demons_kirit8 小时前
Leetcode 2845 题解
算法·leetcode·职场和发展
lkbhua莱克瓦2410 小时前
用C语言实现——一个中缀表达式的计算器。支持用户输入和动画演示过程。
c语言·开发语言·数据结构·链表·学习方法·交友·计算器
lwewan11 小时前
26考研——存储系统(3)
c语言·笔记·考研
Wendy_robot11 小时前
【滑动窗口+哈希表/数组记录】Leetcode 438. 找到字符串中所有字母异位词
c++·算法·leetcode
程序员-King.11 小时前
day49—双指针+贪心—验证回文串(LeetCode-680)
算法·leetcode·贪心算法·双指针
Y1nhl13 小时前
力扣hot100_链表(3)_python版本
python·算法·leetcode·链表·职场和发展
前端 贾公子13 小时前
详解 LeetCode 第 242 题 - 有效的字母组
算法·leetcode·职场和发展
祁同伟.14 小时前
【数据结构 · 初阶】- 堆的实现
c语言·数据结构