62. Unique Paths&机器人走方格I
2015-06-26 09:17
399 查看
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 3 x 7 grid. How many possible unique paths are there?
Note: m and n will be at most 100.
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 3 x 7 grid. How many possible unique paths are there?
Note: m and n will be at most 100.
//最简单的动态规划 //http://www.cnblogs.com/remlostime/archive/2012/11/15/2772263.html class Solution { public: int uniquePaths(int m, int n) { vector<vector<int>> f(m,vector<int>(n)); for(int i = 0;i<m;i++) f[i][0] = 1; for(int j = 0;j<n;j++) f[0][j] = 1; for(int i = 1;i<m;i++) for(int j = 1;j <n;j++) f[i][j] = f[i-1][j] + f[i][j-1]; return f[m-1][n-1]; } };
相关文章推荐
- IOS学习之自定义UITableViewCell
- IOS学习之UIButton
- 【IOS】扩展UIImageViewEx实现:手…
- 基于squashfs的gluebi文件系统开发
- iOS UIFont 字体名字大全
- IOS开发之UIFont应用
- StringBuilder or StringBuffer
- 如何自己编写一个easyui插件
- TrueCrypt 7.1a Hashes
- 关于用Requests模块页面编码的相关
- 设计模式学习--建造者模式
- iOS开发UI篇—创建初始控制器
- 成为设计师的五项技能!最终章!创优翼教育
- 《济源日报》发力电商平台 远丰MallBuilder提供系统支持
- 《济源日报》发力电商平台 远丰MallBuilder提供系统支持
- Answer the questions(回答自己的问题)
- 用UIImageView作出动画效果
- PHP学习笔记(四):require、require_once和include、include_once的区别
- android高仿微信UI点击头像显示大图片效果
- UIControl IOS控件编程—IOS开发