Tell me about yourself. Write code to check if a BST is valid or not.
Anonymous
boolean isBST(TreeNode[] root){ return isBSTU(root, Integer.MIN_VALUE, Integer.MAX_VALUE); } boolean isBSTU(TreeNode root, int min, int max){ if(root==null) return true; if(root.valmax) return false; return (isBSTU(root.left,min,root.data-1) && isBSTU(root.right,root,data+1,max)); }
Check out your Company Bowl for anonymous work chats.