checkHeight that returns the height of the subtree if it is balanced, otherwise returns -1 as an error code.checkHeight on its left and right children.isBalanced calls checkHeight on the root and returns true if the result is not -1, indicating the tree is balanced.