We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9286817 commit 232899dCopy full SHA for 232899d
validate-binary-search-tree/Yu-Won.js
@@ -0,0 +1,20 @@
1
+/**
2
+ * 문제: https://leetcode.com/problems/validate-binary-search-tree/description/
3
+ *
4
+ * 요구사항:
5
+ * root 이진 트리 구조가 주어졌을 때, 해당 트리가 유효한 BST인지 판별하라.
6
7
+ * * */
8
+
9
+const isValidBST = (nums) => {
10
+ const validate = (node, min, max) => {
11
+ if (!node) return true;
12
13
+ if (node.val <= min || node.val >= max) return false;
14
15
+ return validate(node.left, min, node.val) &&
16
+ validate(node.right, node.val, max);
17
+ }
18
19
+ return validate(root, -Infinity, Infinity);
20
+}
0 commit comments