您的位置:首页 > 其它

LintCode(easy)不同的路径

2016-08-26 15:55 302 查看
以下代码超时:

class Solution {
public:
/**
* @param n, m: positive integer (1 <= n ,m <= 100)
* @return an integer
*/
int uniquePaths(int m, int n) {
// wirte your code here
int w;
if (m ==1&& n == 1)  return 1;
if(m==1&&n>1) return 1;
if(n==1&&m>1) return 1;
if(m>1&&n>1)
w=  uniquePaths(m - 1, n) + uniquePaths(m, n - 1);

return w;

}

};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: