Please explain this question and how the code is implemented. Not able to understand from video
Height Balanced tree
Question is that
you have to check whether binary tree is height balance or not
Rules
An empty tree is height-balanced
A non-empty binary tree T is balanced if
- Left subtree of T is balanced
- Right subtree of T is balanced
- The difference between heights of left subtree and right subtree is not more than 1.
Approach
To check if a tree is height-balanced, get the height of left and right subtrees. Return true if difference between heights is not more than 1 and left and right subtrees are balanced, otherwise return false.
now watch the video again
you will understand it