更新代码块
This commit is contained in:
@@ -93,7 +93,7 @@ if (cur == NULL) return cur;
|
||||
|
||||
代码如下:
|
||||
|
||||
```C++
|
||||
```CPP
|
||||
if (cur->val > p->val && cur->val > q->val) {
|
||||
TreeNode* left = traversal(cur->left, p, q);
|
||||
if (left != NULL) {
|
||||
@@ -147,7 +147,7 @@ return cur;
|
||||
|
||||
那么整体递归代码如下:
|
||||
|
||||
```C++
|
||||
```CPP
|
||||
class Solution {
|
||||
private:
|
||||
TreeNode* traversal(TreeNode* cur, TreeNode* p, TreeNode* q) {
|
||||
@@ -177,7 +177,7 @@ public:
|
||||
|
||||
精简后代码如下:
|
||||
|
||||
```C++
|
||||
```CPP
|
||||
class Solution {
|
||||
public:
|
||||
TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) {
|
||||
@@ -198,7 +198,7 @@ public:
|
||||
|
||||
迭代代码如下:
|
||||
|
||||
```C++
|
||||
```CPP
|
||||
class Solution {
|
||||
public:
|
||||
TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) {
|
||||
|
||||
Reference in New Issue
Block a user