[LeetCode] Unique Paths
来源:互联网 发布:爱心机构手机网站源码 编辑:程序博客网 时间:2024/06/12 21:03
int uniquePaths(int m, int n) {int** path = new int*[m];for (int i = 0; i < m; i++){path[i] = new int[n];}for(int r = 0, c = 0; r < m; r++){path[r][c] = 1; }for(int r = 0, c = 0; c < n; c++){path[r][c] = 1; }for(int r = 1; r < m; r++){for(int c = 1; c < n; c++){path[r][c] = path[r-1][c] + path[r][c-1];}}return path[m-1][n-1];}
最初,这么定义数组:int path[m][n]; VS会报这些错:error C2057: 应输入常量表达式,error C2466: 不能分配常量大小为 0 的数组。
因此,改为给数据动态分配内存。
0 0
- leetcode Unique Paths && Unique Paths
- Leetcode-Unique Paths&Unique PathsII
- [LeetCode] Unique Paths and Unique Paths II
- leetcode--Unique Paths && Unique Paths ii
- leetcode--Unique Paths && Unique Paths ii
- 【Leetcode】【python】Unique Paths/Unique Paths II
- LeetCode: Unique Paths
- LeetCode: Unique Paths II
- [Leetcode] Unique Paths
- [Leetcode] Unique Paths II
- LeetCode : Unique Paths
- LeetCode : Unique Paths II
- leetcode 9: Unique Paths
- [LeetCode] Unique Paths
- [LeetCode] Unique Paths II
- [LeetCode]Unique Paths
- [LeetCode]Unique Paths II
- [LeetCode] Unique Paths
- ORA-02020: too many database links in use
- poj3177 Redundant Paths 边双连通分量
- WinForm DataGridView学习小记(1)
- Uploadify 3.2 参数属性、事件、方法函数详解
- 用Linux命令查看当前某个进程A,并查找该进程所占用的端口
- [LeetCode] Unique Paths
- java反射
- android异常——aapt.exe已停止工作
- 网银SSL身份认证
- Web面试总结
- UVa 10125 - Sumsets (中途相遇法 hash)
- ORACLE EBS出现In order to access this application, you must install the J2SE Plugin version 1.6.0_07.
- 最大子序列、最长递增子序列、最长公共子串、最长公共子序列、字符串编辑距离
- 仪表盘设计师访谈录之一 -- RescueTime开发负责人Robby Macdonell