1 public class Solution { 2 public boolean isValidBST(TreeNode root) { 3 return is(root,Integer.MAX_VALUE,Integer.MIN_VALUE); 4 } 5 public boolean is(TreeNode root,int max,int min){ 6 if(root==null) 7 return true; 8 if(root.val<max && root.val>min){ 9 return is(root.left,root.val,min)&&is(root.right,max,root.val); 10 } 11 else return false; 12 } 13 }
相关文章
- 12-21Leetcode 104. Maximum Depth of Binary Tree(二叉树的最大深度)
- 12-21Binary Tree Inorder Traversal
- 12-21Binary Search 的递归与迭代实现及STL中的搜索相关内容
- 12-21LeetCode Binary Tree Preorder Traversal 先根遍历
- 12-21【LeetCode】297. Serialize and Deserialize Binary Tree 解题报告(Python)
- 12-21Binary Tree HDU - 5573 (思维)
- 12-21【LeetCode】109. Convert Sorted List to Binary Search Tree 解题报告(Python)
- 12-21103. Binary Tree Zigzag Level Order Traversal
- 12-21高频刷题-704. Binary Search
- 12-21[LeetCode] 74. Search a 2D Matrix_Medium tag: Binary Search