Skip to content

Commit 9553d47

Browse files
fix: replaced "n+1" to "n-1" in triple-step (careercup#88)
It could be a typo but wrong solution.
1 parent 88b95fd commit 9553d47

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

chapter08/8.01 - Triple Step/tripleStepv2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Recursion and Dynamic Programming (4 steps)
1111
function tripleStep(n) {
1212
if (n < 0) return 0;
1313
if (n === 0) return 1;
14-
return tripleStep(n + 1) + tripleStep(n - 2) + tripleStep(n - 3);
14+
return tripleStep(n - 1) + tripleStep(n - 2) + tripleStep(n - 3);
1515
}
1616

1717
// Top Down Memoization

0 commit comments

Comments
 (0)