C语言 | Leetcode C语言题解之第63题不同路径II

题目:

题解:

cpp 复制代码
int uniquePathsWithObstacles(int** obstacleGrid, int obstacleGridSize,
                             int* obstacleGridColSize) {
    int n = obstacleGridSize, m = obstacleGridColSize[0];
    int f[m];
    memset(f, 0, sizeof(f));
    f[0] = (obstacleGrid[0][0] == 0);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (obstacleGrid[i][j] == 1) {
                f[j] = 0;
                continue;
            }
            if (j - 1 >= 0 && obstacleGrid[i][j - 1] == 0) {
                f[j] += f[j - 1];
            }
        }
    }

    return f[m - 1];
}
相关推荐
伊玛目的门徒8 小时前
试用leetcode之典中典 二数之和问题
java·算法·leetcode
Kx_Triumphs12 小时前
HDU4348 To the moon(主席树区间修改模板)
算法·题解
旖-旎12 小时前
《LeetCode647 回文子串 || LeetCode 5 最长回文子串》
c++·算法·leetcode·动态规划·哈希算法
怪兽学LLM15 小时前
LeetCode 105. 从前序与中序遍历序列构造二叉树:分治递归思路详解
算法·leetcode·职场和发展
退休倒计时16 小时前
【每日一题】LeetCode 39. 组合总和 TypeScript
算法·leetcode·typescript
Scabbards_16 小时前
面试Leetcode - Array
leetcode·面试·职场和发展
无相求码16 小时前
【C语言】字符串的本质是什么,为什么 strlen 会读到野内存
c语言·开发语言
qz5zwangzihan118 小时前
题解:Atcoder Beginner Contest abc466 F - Many Mod Calculation
c++·题解·优先队列·atcoder·大根堆·abc466·abc466f
LuminousCPP18 小时前
C 语言集中实践全记录:顺序表 + 单链表原理实现与通讯录项目实战【附可运行源码】
c语言·开发语言·数据结构·经验分享·笔记
兰令水18 小时前
hot100【acm版】【2026.7.13打卡-java版本】
java·开发语言·数据结构·算法·leetcode·面试