This commit is contained in:
Gyaneshwar Sunkara 2024-07-17 10:43:19 +09:00 committed by GitHub
commit 3221ec5b0d
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 0;
} }
return this.left.height + 1; return this.left.height;
} }
/** /**
@ -37,14 +37,14 @@ export default class BinaryTreeNode {
return 0; return 0;
} }
return this.right.height + 1; return this.right.height;
} }
/** /**
* @return {number} * @return {number}
*/ */
get height() { get height() {
return Math.max(this.leftHeight, this.rightHeight); return Math.max(this.leftHeight, this.rightHeight) + 1;
} }
/** /**