# Find the Minimum and Maximum Height of a Binary Search Tree(problem in test cases)

Tell us what’s happening:
There is problem in test case. My code is passed the test case, but actually on my system I chacked with tree example, it throw an error. So, I think there is problem in test cases.

var displayTree = tree => console.log(JSON.stringify(tree, null, 2));
function Node(value) {
this.value = value;
this.left = null;
this.right = null;
}
function BinarySearchTree() {
this.root = null;
// change code below this line

this.findMaxHeight=function(){
if(this.root===null){
return -1;
}
else{
let ans=findMax(this.root);
}
}
function findMax(tree){
let lans=0;
let rans=0;
if(tree.left!==null){
lans=1;
lans+=findMax(tree.left);
}
else if(tree.right!==null){
rans=1;
rans+=findMax(tree.left);
}
else{
return 1;
}
if(lans>rans){
return lans;
}
else{
return rans;
}
}

this.findMinHeight=function(){
//if tree is empty
if(this.root===null){
return -1;
}
else{
let ans=findMin(this.root);
return ans+1;
}
}
function findMin(tree){
let lans=0;
let rans=0;
if(tree.left!==null){
lans+=findMin(tree.left);
}
else if(tree.right!==null){
rans+=findMin(tree.left);
}
else{
return 1;
}
if(lans<rans){
return lans;
}
else{
return rans;
}
}

// change code above this line
}