Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b5c7739

Browse files
authored
Update 98.validate-binary-search-tree.md
格式化
1 parent b8a7689 commit b5c7739

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

problems/98.validate-binary-search-tree.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -325,17 +325,17 @@ JavaScript Code:
325325
* @param {TreeNode} root
326326
* @return {boolean}
327327
*/
328-
var isValidBST = function(root) {
329-
if(!root)return true;
330-
return valid(root);
328+
var isValidBST = function (root) {
329+
if (!root) return true;
330+
return valid(root);
331331
};
332332

333-
function valid(root,min = -Infinity,max=Infinity){
334-
if(!root)return true;
335-
const val = root.val;
336-
if(val<=min)return false;
337-
if(val>=max)return false;
338-
return valid(root.left,min,val)&&valid(root.right,val,max)
333+
function valid(root, min = -Infinity, max = Infinity) {
334+
if (!root) return true;
335+
const val = root.val;
336+
if (val <= min) return false;
337+
if (val >= max) return false;
338+
return valid(root.left, min, val) && valid(root.right, val, max)
339339
}
340340
```
341341

0 commit comments

Comments
 (0)