leetcode.62.不同路径——动态规划必刷题dp

leetcode.62.不同路径

不同路径

在这里插入图片描述

public int uniquePaths(int m, int n) {
    int[][] dp = new int[m][n];
    //第一列都是1
    for (int i = 0; i < m; i++) {
        dp[i][0] = 1;
    }
    //第一行都是1
    for (int i = 0; i < n; i++) {
        dp[0][i] = 1;
    }

    //这里是递推公式
    for (int i = 1; i < m; i++)
        for (int j = 1; j < n; j++)
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
    return dp[m - 1][n - 1];
}

动态规划必刷题

Easy Min Cost Climbing Stairs https://leetcode.com/problems/min-cost-climbing-stairs C++
Easy Climbing Stairs https://leetcode.com/problems/climbing-stairs C++
Easy Unique Paths https://leetcode.com/problems/unique-paths/ C++
Medium Minimum Path Sum https://leetcode.com/problems/minimum-path-sum/ C++
Easy Maximum Subarray https://leetcode.com/problems/maximum-subarray/ C++
Medium Maximum Product Subarray https://leetcode.com/problems/maximum-product-subarray/ C++
Easy Best Time to Buy and Sell Stock https://leetcode.com/problems/best-time-to-buy-and-sell-stock C++
Easy Best Time to Buy and Sell Stock II https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/ C++
Hard Best Time to Buy and Sell Stock III https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/ C++
Hard Best Time to Buy and Sell Stock IV https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/ C++
Medium Best Time to Buy and Sell Stock with Cooldown https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/ C++
Medium Best Time to Buy and Sell Stock with Transaction Fee https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee C++
Medium Coin Change https://leetcode.com/problems/coin-change C++
Medium Coin Change 2 https://leetcode.com/problems/coin-change-2 C++
Hard Edit Distance https://leetcode.com/problems/edit-distance C++
Hard Distinct Subsequences https://leetcode.com/problems/distinct-subsequences/ C++
Hard Largest Rectangle in Histogram https://leetcode.com/problems/largest-rectangle-in-histogram/ C++
Hard Maximal Rectangle https://leetcode.com/problems/maximal-rectangle/ C++
Medium Maximal Square https://leetcode.com/problems/maximal-square/ C++
Medium Minimum Cost For Tickets https://leetcode.com/problems/minimum-cost-for-tickets/ C++
Easy Range Sum Query - Immutable https://leetcode.com/problems/range-sum-query-immutable/ C++
Medium Range Sum Query 2D - Immutable https://leetcode.com/problems/range-sum-query-2d-immutable/ C++
Medium Longest Increasing Subsequence https://leetcode.com/problems/longest-increasing-subsequence C++

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值