leetcode62—Unique Paths
2023-12-02 04:18:04
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 = 2 Output: 3 Explanation: From the top-left corner, there are a total of 3 ways to reach the bottom-right corner: 1. Right -> Right -> Down 2. Right -> Down -> Right 3. Down -> Right -> Right
Example 2:
Input: m = 7, n = 3 Output: 28
想法:采用动态规划,确立状态转移表达式f(m,n)=f(m-1,n)+f(n-1,m)表示可能性。
class Solution { public: int uniquePaths(int m, int n) { int result[m][n]; ; i < m ; i++){ ; j < n ; j++){ == i || == j){ result[i][j] = ; continue; } result[i][j] = result[i-][j] + result[i][j-]; } } ][n-]; } };
最新文章
- 微信小程序小技巧系列《二》show内容展示,上传文件编码问题
- 如何解决google ping不通的问题。
- 通过编程发现Java死锁
- PHPRPC jsp发布服务
- 关于Redis的启动过程
- centos升级mysql至5.7
- jQuery图片无缝滚动JS代码ul/li结构
- 【面试题043】n个骰子的点数
- 在同一台机器上让Microsoft SQL Server 2000/ SQL2005/ SQL2008共存
- apache php gzip压缩输出的实现方法
- char图表
- linux中BASH_SOURCE[0]
- Visual Studio跨平台开发实战(5) - Xamarin Android多页面应用程式开发
- Java不走弯路教程(3.用户验证与文件内容查询)
- java反射获取Object的属性和值
- 公众号第三方平台开发 教程六 代公众号使用JS SDK说明
- js 算數(Math)對象
- linux中cmake语法的学习
- 廖雪峰Java1-2程序基础-9数组
- 一个Form表单多个Submit提交按钮!实现提交不同的参数!
热门文章
- Java - Stack源码解析
- 你不知道的JavasScript上篇&#183;第五章&#183;原型&#183;下
- bzoj P5016[Snoi2017]一个简单的询问——solution
- BFC(块状格式化上下文)
- Postman&#160;Postman测试接口之JSON结构化数据提交
- 闲聊jQuery(一)
- web调试-禁止/清空chrome页面缓存
- The current identity ( XXXX) does not have write access to ‘C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files’.解决办法
- C#读取AD域用户信息
- 通用视图-分开处理GET、POST请求