You are given the root of a binary tree.
Your task is to determine if the given binary tree is height-balanced. A binary tree is considered height-balanced if, for every node in the tree, the depth of its left subtree and the depth of its right subtree differ by no more than one.
Note that:
nodes) is considered height-balanced.Return true if the binary tree is height-balanced, and false otherwise.
True
The tree is balanced as both left and right subtrees of the root have a height of 1.
True
The tree is balanced as the left subtree is empty (height 0) and the right subtree has a height of 1.
False
For node 1, the left subtree has a height of 2 (path 1->2->3) and the right subtree has a height of 0. The difference is 2, which is greater than 1.
True