Is it balanced?


Collapse Content

Can you check if a tree is a height-balanced?

In this challenge, a tree is height-balanced if the maximum and minimum path from any node to a terminal (null node) descendant differs my at most 1.

For example, this tree is not height-balanced, since the minimum path going down from 5 (to the left) is 2 less than the maximum path from 5 (to 9 and 4).

Challenge

Print true if a given tree is height-balanced and false otherwise.

Please sign in or sign up to submit answers.

Alternatively, you can try out Learneroo before signing up.

Comments

Contact Us
Sign in or email us at [email protected]