is_balanced(Binary tree)


I am not understanding how to define the height and balance variables.There is a problem in taking the input.Please help.

@srshubhi398 hi, you can take a pair<height, isbalanced> of type <int, bool> for each node.
In the base case return {0, true} and for the rest of the nodes you can make the answer accordingly.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.