博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Leetcode: Unique Paths
阅读量:4542 次
发布时间:2019-06-08

本文共 730 字,大约阅读时间需要 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?

推荐方法:DP矩阵做法其实还可以节省一维:2D矩阵变成一维数组DP:

1 public int uniquePaths(int m, int n) { 2     if(m<=0 || n<=0) 3         return 0; 4     int[] res = new int[n]; 5     res[0] = 1; 6     for(int i=0;i

一维DP方法2:

1 public class Solution { 2     public int uniquePaths(int m, int n) { 3         if (m == 0 || n == 0) return 0; 4         int[] res = new int[n]; 5         for (int k=0; k

 

转载于:https://www.cnblogs.com/EdwardLiu/p/3726907.html

你可能感兴趣的文章
WORD2003电子签名插件(支持手写、签章)
查看>>
Google开源项目二维码读取与生成工具ZXing
查看>>
Android使用默认样式创建View的几个姿势
查看>>
多标记学习--Learning from Multi-Label Data
查看>>
leetcode 47. 全排列 II
查看>>
1083 List Grades (25)
查看>>
使用iptables和tc对端口限速
查看>>
14、反射(reflect)
查看>>
树-哈夫曼树
查看>>
异步复位同步释放
查看>>
【Spark2.0源码学习】-7.Driver与DriverRunner
查看>>
poj 1206
查看>>
Spring基础系列-参数校验
查看>>
php+ajax实现图片文件上传功能
查看>>
SQL日期格式化及创建相关日期
查看>>
模式识别--概率密度
查看>>
linux 安装虚拟机
查看>>
Notepad++的ftp远程编辑功能
查看>>
bootstrap中弹出窗体dialog的自定义
查看>>
java 操作数据库
查看>>