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;
}
相关推荐
雪花desu几秒前
【Hot100-Java中等】:字母异位词分组
java·算法·leetcode·哈希表
Word码2 分钟前
LeetCode283. 移动零(双指针精讲)
算法·leetcode·职场和发展
YGGP9 分钟前
【Golang】LeetCode 55. 跳跃游戏
算法·leetcode
练习时长一年2 小时前
Leetcode热题100(跳跃游戏 II)
算法·leetcode·游戏
小白菜又菜8 小时前
Leetcode 3432. Count Partitions with Even Sum Difference
算法·leetcode
wuhen_n9 小时前
LeetCode -- 15. 三数之和(中等)
前端·javascript·算法·leetcode
sin_hielo9 小时前
leetcode 2483
数据结构·算法·leetcode
sevenez9 小时前
Vibe Coding 实战笔记:从“修好了C坏了AB”到企业级数据库架构重构
c语言·笔记·数据库架构
一路往蓝-Anbo10 小时前
【第20期】延时的艺术:HAL_Delay vs vTaskDelay
c语言·数据结构·stm32·单片机·嵌入式硬件
wuhen_n11 小时前
LeetCode -- 1:两数之和(简单)
javascript·算法·leetcode·职场和发展