Skip to content

Commit f3a46a3

Browse files
committed
Day67
1 parent 8ed0e6f commit f3a46a3

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

Day67/index.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Definition for a binary tree node.
3+
* function TreeNode(val, left, right) {
4+
* this.val = (val===undefined ? 0 : val)
5+
* this.left = (left===undefined ? null : left)
6+
* this.right = (right===undefined ? null : right)
7+
* }
8+
*/
9+
/**
10+
* @param {TreeNode} root
11+
* @return {boolean}
12+
*/
13+
var isValidBST = function (root) {
14+
15+
16+
function helper(node, min, max) {
17+
if (!node) return true;
18+
19+
if (node.val <= min || node.val >= max) return false;
20+
21+
let left = helper(node.left, min, node.val);
22+
let right = helper(node.right, node.val, max)
23+
24+
return left && right
25+
26+
}
27+
28+
return helper(root, -Infinity, Infinity)
29+
};

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,8 @@ If you are loving solving problems in leetcode, please contact me to enjoy it to
147147

148148
|Day 64| [131. Palindrome Partitioning](https://leetcode.com/problems/squares-of-a-sorted-array/) | [javascript]()|[:memo:](https://leetcode.com/problems/squares-of-a-sorted-array/)|Easy|
149149

150-
|Day 65| [1485. Clone Binary Tree With Random Pointer](https://leetcode.com/problems/clone-binary-tree-with-random-pointer/) | [javascript]()|[:memo:](https://leetcode.com/problems/clone-binary-tree-with-random-pointer/)|Medium|
150+
|Day 65| [1485. Clone Binary Tree With Random Pointer](https://leetcode.com/problems/clone-binary-tree-with-random-pointer/) | [javascript]()|[:memo:](https://leetcode.com/problems/clone-binary-tree-with-random-pointer/)|Medium|
151+
152+
|Day 66| [1485. Clone Binary Tree With Random Pointer](https://leetcode.com/problems/clone-binary-tree-with-random-pointer/) | [javascript]()|[:memo:](https://leetcode.com/problems/clone-binary-tree-with-random-pointer/)|Medium|
153+
154+
|Day 67| [98. Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree/) | [javascript]()|[:memo:](https://leetcode.com/problems/validate-binary-search-tree/)|Medium|

0 commit comments

Comments
 (0)