62. Unique Paths
来源:互联网 发布:淘宝新手卖家交流群 编辑:程序博客网 时间:2024/06/06 12:58
#include <iostream>#include <stdio.h>#include <vector>using namespace std;class Solution {public: int uniquePaths(int m, int n) {//超时!!!!! if(m==1 && n==1)return 1;if(m<1 || n<1)return 0;int paths=0;paths+=uniquePaths(m-1,n);paths+=uniquePaths(m,n-1);return paths; }int uniquePaths2(int m, int n) {//动态规划 if (m > n) return uniquePaths(n, m); vector<int> cur(m, 1); for (int j = 1; j < n; j++) for (int i = 1; i < m; i++) cur[i] += cur[i - 1]; return cur[m - 1]; }};int main(){Solution mys;cout<<mys.uniquePaths(1,5)<<endl;cout<<mys.uniquePaths2(1,5)<<endl;return 0;}
阅读全文
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
- 用tomcat发布自己的Java项目
- UVA 11059
- lightoj 1009 Back to Underworld (种类并查集)
- 一些网址
- Unity宠物跟随
- 62. Unique Paths
- linux(本机)配置域名(多域名)
- MATLAB 2D 矩阵围绕中心旋转
- 用 线性回归 预测股票的涨跌
- Echarts柱状图,饼状图
- IDEA中创建maven项目---工作记录
- 根据先根序列创建二叉树
- PHP测试题
- ES6 箭头函数中的 this