祝福真灵啊,爸妈一次签过。# NextGeneration - 我爱宝宝
f*u
1 楼
下面这段代码是Leetcode上面Unique Paths的最基本的recursion算法。它的算法复杂
度咋算?哪个高手给解释一下,多谢!
int uniquePaths(int m, int n) {
if (m < 1 || n < 1) return 0;
if (m == 1 && n == 1) return 1;
return uniquePaths(m - 1, n) + uniquePaths(m, n - 1);
}
度咋算?哪个高手给解释一下,多谢!
int uniquePaths(int m, int n) {
if (m < 1 || n < 1) return 0;
if (m == 1 && n == 1) return 1;
return uniquePaths(m - 1, n) + uniquePaths(m, n - 1);
}