leetCode62. 不同路径

leetCode62. 不同路径

题目思路

代码

cpp 复制代码
class Solution {
public:
    int uniquePaths(int m, int n) {
        // m行n列
        vector<vector<int>> f(m, vector<int> (n));
        for(int i = 0; i < m; i++){
            for(int j = 0; j < n; j++){
                if(!i && !j) f[i][j] = 1;
                else{
                    if(i) f[i][j] += f[i - 1][j];
                    if(j) f[i][j] += f[i][j - 1];
                }
            }
        }

        return f[m - 1][n - 1];
    }
};
相关推荐
历程里程碑13 小时前
双指针2--盛水最多的容器
大数据·数据结构·算法·leetcode·elasticsearch·搜索引擎·散列表
June bug13 小时前
(#数组/链表操作)寻找两个正序数组的中位数
数据结构·python·算法·leetcode·面试·职场和发展·跳槽
TracyCoder12313 小时前
LeetCode Hot100(8/100)—— 438. 找到字符串中所有字母异位词
算法·leetcode
June bug14 小时前
(#数组/链表操作)最长上升子序列的长度
数据结构·程序人生·leetcode·链表·面试·职场和发展·跳槽
hadage23314 小时前
--- 力扣oj柱状图中最大的矩形 单调栈 ---
算法·leetcode·职场和发展
json{shen:"jing"}14 小时前
18. 四数之和
数据结构·算法·leetcode
多米Domi01115 小时前
0x3f 第42天 复习 10:39-11:33
算法·leetcode
议题一玩到15 小时前
#leetcode# 1984. Minimum Difference Between Highest and Lowest of K Scores
数据结构·算法·leetcode
漫随流水15 小时前
leetcode回溯算法(90.子集Ⅱ)
数据结构·算法·leetcode·回溯算法
June bug16 小时前
(#数组/链表操作)合并两个有重复元素的无序数组,返回无重复的有序结果
数据结构·python·算法·leetcode·面试·跳槽