mirror of
https://github.com/krahets/hello-algo.git
synced 2025-02-02 22:43:50 +08:00
Fix: recursion bug for JS and TS (#1028)
This commit is contained in:
parent
edf3f3e33a
commit
0f5b924036
@ -20,7 +20,7 @@ function forLoopRecur(n) {
|
||||
const stack = [];
|
||||
let res = 0;
|
||||
// 递:递归调用
|
||||
for (let i = 1; i <= n; i++) {
|
||||
for (let i = n; i > 0; i--) {
|
||||
// 通过“入栈操作”模拟“递”
|
||||
stack.push(i);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ function forLoopRecur(n: number): number {
|
||||
const stack: number[] = [];
|
||||
let res: number = 0;
|
||||
// 递:递归调用
|
||||
for (let i = 1; i <= n; i++) {
|
||||
for (let i = n; i > 0; i--) {
|
||||
// 通过“入栈操作”模拟“递”
|
||||
stack.push(i);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user