其他分享
首页 > 其他分享> > 动态归划之不同路径走法之和

动态归划之不同路径走法之和

作者:互联网

# -*- encoding : utf-8 -*-
# @Author : 日落了
# @ Motto : 天不生python,IT 万古如长夜
# @project_name : DUOyi
# @Time : 2021/12/28
# @description : 

matrix = [[0 for i in range(3)] for i in range(3)]


def uniquePaths1(m: int, n: int) -> int:
    dp = [[0 for col in range(n)] for row in range(m)]
    # 定义边界
    for i in range(m):
        dp[i][0] = 1
    for j in range(n):
        dp[0][j] = 1
    if m < 0 or n < 0:
        return -1
    for i in range(1, m):
        for j in range(1, n):
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1]

    return dp[m - 1][n - 1]


if __name__ == '__main__':
    print(uniquePaths1(3, 7))

 

标签:__,return,name,归划,走法,int,路径,range,dp
来源: https://www.cnblogs.com/icxk/p/15747296.html