This commit is contained in:
krahets
2023-11-27 02:32:06 +08:00
parent 32d5bd97aa
commit a4a23e2488
31 changed files with 179 additions and 213 deletions

View File

@ -126,9 +126,9 @@ comments: true
/* 爬楼梯:回溯 */
int ClimbingStairsBacktrack(int n) {
List<int> choices = new() { 1, 2 }; // 可选择向上爬 1 或 2 阶
List<int> choices = [1, 2]; // 可选择向上爬 1 或 2 阶
int state = 0; // 从第 0 阶开始爬
List<int> res = new() { 0 }; // 使用 res[0] 记录方案数量
List<int> res = [0]; // 使用 res[0] 记录方案数量
Backtrack(choices, state, n, res);
return res[0];
}