Merge pull request #151 from csresource04/master

更新0035.搜索插入位置  0257.二叉树的所有路径  Markdown代码块语法
This commit is contained in:
Carl Sun
2021-05-16 21:21:23 +08:00
committed by GitHub
2 changed files with 6 additions and 6 deletions

View File

@ -116,7 +116,7 @@ public:
**大家要仔细看注释思考为什么要写while(left <= right) 为什么要写right = middle - 1**
```
```C++
class Solution {
public:
int searchInsert(vector<int>& nums, int target) {
@ -158,7 +158,7 @@ public:
**大家要仔细看注释思考为什么要写while (left < right) 为什么要写right = middle**。
```
```C++
class Solution {
public:
int searchInsert(vector<int>& nums, int target) {

View File

@ -77,7 +77,7 @@ if (cur->left == NULL && cur->right == NULL) {
这里我们先使用vector<int>结构的path容器来记录路径那么终止处理逻辑如下
```
```C++
if (cur->left == NULL && cur->right == NULL) { // 遇到叶子节点
string sPath;
for (int i = 0; i < path.size() - 1; i++) { // 将path里记录的路径转为string格式
@ -113,7 +113,7 @@ if (cur->right) {
那么回溯要怎么回溯呢,一些同学会这么写,如下:
```
```C++
if (cur->left) {
traversal(cur->left, path, result);
}
@ -129,7 +129,7 @@ path.pop_back();
那么代码应该这么写:
```
```C++
if (cur->left) {
traversal(cur->left, path, result);
path.pop_back(); // 回溯
@ -335,4 +335,4 @@ Go
* 作者微信:[程序员Carl](https://mp.weixin.qq.com/s/b66DFkOp8OOxdZC_xLZxfw)
* B站视频[代码随想录](https://space.bilibili.com/525438321)
* 知识星球:[代码随想录](https://mp.weixin.qq.com/s/QVF6upVMSbgvZy8lHZS3CQ)
<div align="center"><img src=../pics/公众号.png width=450 alt=> </img></div>
<div align="center"><img src=../pics/公众号.png width=450 alt=> </img></div>