This commit is contained in:
Gyaneshwar Sunkara 2024-03-09 16:08:15 -07:00 committed by GitHub
commit ee6299dad1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,7 +26,7 @@ export default class BinaryTreeNode {
return 0;
}
return this.left.height + 1;
return this.left.height;
}
/**
@ -37,14 +37,14 @@ export default class BinaryTreeNode {
return 0;
}
return this.right.height + 1;
return this.right.height;
}
/**
* @return {number}
*/
get height() {
return Math.max(this.leftHeight, this.rightHeight);
return Math.max(this.leftHeight, this.rightHeight) + 1;
}
/**