File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ Explanation: The root node's value is 5 but its right child's value is 4.
41
41
我们只需要中序遍历,然后两两判断是否有逆序的元素对即可,如果有,则不是BST,否则即为一个BST。
42
42
43
43
### 定义法
44
- 根据定义,一个结点若是在根的左子树上,那它应该小于根结点的值而大于左子树最大值 ;若是在根的右子树上,那它应该大于根结点的值而小于右子树最小值 。也就是说,每一个结点必须落在某个取值范围:
44
+ 根据定义,一个结点若是在根的左子树上,那它应该小于根结点的值而大于左子树最小值 ;若是在根的右子树上,那它应该大于根结点的值而小于右子树最大值 。也就是说,每一个结点必须落在某个取值范围:
45
45
1 . 根结点的取值范围为(考虑某个结点为最大或最小整数的情况):(long_min, long_max)
46
46
2 . 左子树的取值范围为:(current_min, root.value)
47
47
3 . 右子树的取值范围为:(root.value, current_max)
@@ -151,7 +151,7 @@ public:
151
151
};
152
152
```
153
153
154
- Java Implementation
154
+ Java Code:
155
155
156
156
```java
157
157
/**
@@ -311,7 +311,7 @@ class Solution {
311
311
}
312
312
```
313
313
314
- JS Code:
314
+ JavaScript Code:
315
315
316
316
``` javascript
317
317
/**
You can’t perform that action at this time.
0 commit comments