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

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

class Solution {public:    int uniquePaths(int m, int n) {		std::vector
> dp(m,std::vector
(n,0)); for (int i = 0; i < m; i++) { dp[i][0] = 1; } for (int i = 0; i < n; i++) { dp[0][i] = 1; } for (int i = 1; i < m; i++) { for (int j = 1; j < n; j++) { dp[i][j] = dp[i-1][j] + dp[i][j-1]; } } return dp[m-1][n-1]; }};

转载于:https://www.cnblogs.com/hrhguanli/p/5085957.html

你可能感兴趣的文章
POJ-数据结构-优先队列模板
查看>>
【HAOI2006】旅行(并查集暴力)
查看>>
css实现文本超出部分省略号显示
查看>>
留言板
查看>>
vue-router组件状态刷新消失的问题
查看>>
Android UI开发第十四篇——可以移动的悬浮框
查看>>
java8的一些用法
查看>>
(十)Hive分析窗口函数(二) NTILE,ROW_NUMBER,RANK,DENSE_RANK
查看>>
2018-11-19站立会议内容
查看>>
第五次作业 关于《构建之法》的心得体会
查看>>
Memo打印1
查看>>
AtCoder Grand Contest 010 --C:Cleaning
查看>>
Memcached 笔记与总结(3)安装 php-memcache(windows 系统下)
查看>>
Android2.2中添加的match_parent和fill_parent没有区别
查看>>
POJ 1251 Jungle Roads (prim)
查看>>
IOS_画图 图片等比压缩 IOS_UIImage
查看>>
刘关张三结义(第七次作业)
查看>>
Redis学习笔记(十一) 命令进阶:Connection(连接)
查看>>
memcached与redis 对比
查看>>
JVM 入门三板斧
查看>>