Validate Binary Search Tree

Validate Binary Search Tree
 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 }
View Code

Validate Binary Search Tree

上一篇:Windows基础学习


下一篇:C# WPF从RIOT API获取数据(RIOT代表作品《英雄联盟》)