题目:不同路径的数目(一)_牛客题霸_牛客网 (nowcoder.com)
题解:
明显可以用递归来解决
在边长m或者n为1的时候,只有一条路可走
在不为1的时候,递归调用函数即可出结果
class Solution {
public:
/**
*
* @param m int整型
* @param n int整型
* @return int整型
*/
int uniquePaths(int m, int n) {
// write code here
int out;
if (m==1 || n==1) return 1;
out=uniquePaths(m-1, n)+uniquePaths(m, n-1);
return out;
}
};