Skip to content

Commit 8a9f413

Browse files
committed
Update
1 parent 4891f8a commit 8a9f413

File tree

6 files changed

+11
-0
lines changed

6 files changed

+11
-0
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public boolean isValidBST(TreeNode root) {
3+
return isValidBST(root, Long.MIN_VALUE, Long.MAX_VALUE);
4+
}
5+
6+
private boolean isValidBST(TreeNode root, long min, long max){
7+
if(root == null) return true;
8+
if(root.val = max root.val = min) return false;
9+
return isValidBST(root.left, min, root.val) && isValidBST(root.right, root.val, max);
10+
}
11+
}

0 commit comments

Comments
 (0)