From ed199f1f75199ab9daf487c0c6b99d467f1cef43 Mon Sep 17 00:00:00 2001 From: zhicheng lee <904688436@qq.com> Date: Wed, 24 Aug 2022 21:31:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=200077.=E7=BB=84=E5=90=88?= =?UTF-8?q?=E4=BC=98=E5=8C=96.md=20cpp=E4=BB=A3=E7=A0=81=E8=AF=AD=E6=B3=95?= =?UTF-8?q?=E9=AB=98=E4=BA=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 网站本文cpp代码没有语法高亮,推测网站可以识别```CPP(网站其它cpp代码均用```CPP标识),但无法识别```c++ --- problems/0077.组合优化.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/problems/0077.组合优化.md b/problems/0077.组合优化.md index e336fb75..b8b5f3c1 100644 --- a/problems/0077.组合优化.md +++ b/problems/0077.组合优化.md @@ -20,7 +20,7 @@ 大家先回忆一下[77. 组合]给出的回溯法的代码: -```c++ +```CPP class Solution { private: vector> result; // 存放符合条件结果的集合 @@ -52,7 +52,7 @@ public: 在遍历的过程中有如下代码: -```c++ +```CPP for (int i = startIndex; i <= n; i++) { path.push_back(i); backtracking(n, k, i + 1); @@ -76,7 +76,7 @@ for (int i = startIndex; i <= n; i++) { **如果for循环选择的起始位置之后的元素个数 已经不足 我们需要的元素个数了,那么就没有必要搜索了**。 注意代码中i,就是for循环里选择的起始位置。 -```c++ +```CPP for (int i = startIndex; i <= n; i++) { ``` @@ -98,13 +98,13 @@ for (int i = startIndex; i <= n; i++) { 所以优化之后的for循环是: -```c++ +```CPP for (int i = startIndex; i <= n - (k - path.size()) + 1; i++) // i为本次搜索的起始位置 ``` 优化后整体代码如下: -```c++ +```CPP class Solution { private: vector> result;