62. Unique Paths
来源:互联网 发布:在线大肚照自拍软件 编辑:程序博客网 时间:2024/04/29 20:24
Unique Paths
从起点走到终点有多少种方法
思路
使用简单的动态规划:
首先对两边进行赋值 因为机器人不能向上走 或者向左走 所以两边的格子里都是1 其次再通过动态规划【F(m)(n)=F(m-1)(n)+F(m)(n-1)】计算走到最后一格有多少种方法
代码
public class Solution { public int uniquePaths(int m, int n) { int[][] grid = new int[m][n]; for(int i = 0; i<m; i++){ for(int j = 0; j<n; j++){ if(i==0||j==0) grid[i][j] = 1; else grid[i][j] = grid[i][j-1] + grid[i-1][j]; } } return grid[m-1][n-1]; }}
0 0
- 62. Unique Paths && 63. Unique Paths II
- 62. Unique Paths \ 63. Unique Paths II
- [LeetCode]62.Unique Paths
- LeetCode --- 62. Unique Paths
- LeetCode 62.Unique Paths
- [Leetcode] 62. Unique Paths
- [leetcode] 62.Unique Paths
- 62. Unique Paths
- [leetcode] 62.Unique Paths
- leetcode 62. Unique Paths
- Leetcode 62. Unique Paths
- [leetcode] 62. Unique Paths
- 62. Unique Paths LeetCode
- 62. Unique Paths
- 62. Unique Paths
- [LeetCode]62. Unique Paths
- 【LeetCOde】62. Unique Paths
- [LeetCode]62. Unique Paths
- //6.5 定义一个日期类 Date,该类对象存放一个日期,可以提供的操作有: //void GetDate(); //取日期值,格式如“2001 年 2 月 5 日” //void GetYear(
- 思考各种编程语言是如何适应运行环境(调用外设)的?
- View setSystemUiVisible 测试
- 随机数字的大小排列
- 并发编程
- 62. Unique Paths
- 第五周实践项目1————三角形雏形(4)
- 微软认知服务开发实践(1) - 牛津计划简介
- C++11中使用shared_ptr和unique_ptr管理动态数组
- bootstrap中按钮点击会自动刷新解决
- c++第二次实验-1
- HDU 1056
- VMware workstation NAT方式无法连接外网
- C++中map容器的使用