Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2d36391

Browse files
committed
update: 98
1 parent2d9e782 commit2d36391

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ This is the solutions collection of my LeetCode submissions, most of them are pr
5252
|88|[Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array/)|[JavaScript](./src/merge-sorted-array/res.js)|Medium|
5353
|91|[Decode Ways](https://leetcode.com/problems/decode-ways/)|[JavaScript](./src/decode-ways/res.js)|Medium|
5454
|93|[Restore IP Addresses](https://leetcode.com/problems/restore-ip-addresses/)|[JavaScript](./src/restore-ip-addresses/res.js)|Medium|
55+
|98|[Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree/)|[JavaScript](./src/validate-binary-search-tree/res.js)|Medium|
5556
|100|[Same Tree](https://leetcode.com/problems/same-tree/)|[JavaScript](./src/same-tree/res.js)|Easy|
5657
|101|[Symmetric Tree](https://leetcode.com/problems/symmetric-tree/)|[JavaScript](./src/symmetric-tree/res.js)|Easy|
5758
|102|[Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/)|[JavaScript](./src/binary-tree-level-order-traversal/res.js)|Medium|
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Definition for a binary tree node.
3+
* function TreeNode(val) {
4+
* this.val = val;
5+
* this.left = this.right = null;
6+
* }
7+
*/
8+
/**
9+
*@param {TreeNode} root
10+
*@return {boolean}
11+
*/
12+
varisValidBST=function(root){
13+
if(!root)returntrue;
14+
15+
constvalidSubBST=(element,low,high)=>{
16+
if(low!==null&&low>=element.val)returnfalse;
17+
if(high!==null&&high<=element.val)returnfalse;
18+
if(!element.left&&!element.right)returntrue;
19+
20+
if(element.left&&!validSubBST(element.left,low,element.val))returnfalse;
21+
if(element.right&&!validSubBST(element.right,element.val,high))returnfalse;
22+
23+
returntrue;
24+
}
25+
26+
returnvalidSubBST(root,null,null);
27+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp