博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
62. Unique Paths(矩阵的总路径数)
阅读量:6947 次
发布时间:2019-06-27

本文共 843 字,大约阅读时间需要 2 分钟。

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).

The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).

How many possible unique paths are there?

Above is a 7 x 3 grid. How many possible unique paths are there?

Note: m and n will be at most 100.

Example 1:

Input: m = 3, n = 2Output: 3Explanation:From the top-left corner, there are a total of 3 ways to reach the bottom-right corner:1. Right -> Right -> Down2. Right -> Down -> Right3. Down -> Right -> Right

Example 2:

Input: m = 7, n = 3Output: 28 题目描述:统计从矩阵左上角到右下角的路径总数,每次只能向右或者向下移动 分析:先举例再总结规律,第一列的路径只能有一条,第一行同理。dp[1][1] 就有两条,上面一条,左边一条。所以得到公式 dp[i][j]=dp[i-1][j]+dp[i][j-1]

 

 

转载于:https://www.cnblogs.com/shaer/p/10520384.html

你可能感兴趣的文章
Linux 小知识翻译 - 「BitTorrent」
查看>>
spark java api数据分析实战
查看>>
计算机学院大学生程序设计竞赛(2015’12) 1001 The Country List
查看>>
CodeForces 689E Mike and Geometry Problem
查看>>
Netty是什么?
查看>>
Java Web学习笔记--JSP for循环
查看>>
Windows Server 2012 R2 里面如何安装Net Framework 3.5
查看>>
ERROR 1366 (HY000): Incorrect string value:MySQL数据库、表的字符集为GBK
查看>>
Linux系统安装过程
查看>>
css flex布局
查看>>
如何高效完成英文文献翻译
查看>>
Unity 射线 Ray
查看>>
SVG绘制loading效果
查看>>
移植性问题の[windows编程]error C2664: “MessageBoxW”: 不能将参数 2 从“char *”转......
查看>>
InheritableThreadLocal类原理简介使用 父子线程传递数据详解 多线程中篇(十八)...
查看>>
MVC插件实现
查看>>
Swift学习笔记1---变量和元组
查看>>
FTP权限问题解析,553 Can't open that file: Permission denied
查看>>
阿里云服务器重置后远程链接失败的解决办法
查看>>
POJ 3159 差分约束
查看>>