Unique Paths
来源:互联网 发布:菜鸟学java 编辑:程序博客网 时间:2024/06/05 18:31
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) {int** p; int result;p= new int*[m];for (int i = 0; i <m; i++){ p[i] = new int[n];}for (int i = 0; i <m; i++){p[i][0] = 1;}for (int i = 0; i <n; i++){ p[0][i] = 1;}for (int i = 1; i <m; i++){for (int j = 1; j <n; j++){p[i][j] = p[i-1][j] + p[i][j-1];}}result = p[m-1][n-1];for (int i = 0; i <m; i++){delete p[i];}delete p;return result;}};
0 0
- Unique Paths
- Unique Paths
- Unique Paths
- Unique Paths
- Unique Paths
- Unique Paths
- Unique Paths
- Unique Paths
- Unique Paths
- Unique Paths
- Unique Paths
- Unique Paths
- Unique Paths
- Unique Paths
- Unique Paths
- Unique Paths
- Unique Paths
- Unique Paths
- 证明0.999999...(无限循环)=1 的一种搞siao非主流方法。。。
- Android手动添加布局
- Java编程算法基础----递归与循环关系
- javaweb之Maven项目管理工具学习
- 【日志】新手对接口的自我理解(帮忙指正,谢谢)
- Unique Paths
- nginx在linux下的安装
- 【Java.Web】Servlet —— 请求的重定向
- Bull Math(java大数相乘)
- FEDERATED存储引擎的使用,如何开启FEDERATED,FEDERATED Support NO?
- 学习了这么久,资料整理了一大堆,马上毕业了,开始写写博客,以后慢慢看。。
- Binary Tree Inorder Traversal
- 一.贪心算法 喷水装置(一)
- PAT 2-11 两个有序链表序列的合并(C语言实现)