PROBLEM OF THE DAY: 11/10/2023 | Check for Balanced Tree
source link: https://www.geeksforgeeks.org/videos/problem-of-the-day-11102023-check-for-balanced-tree/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
PROBLEM OF THE DAY: 11/10/2023
Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Binary Tree but will also help you build up problem-solving skills.
In this problem, we are given, a binary tree, to find if it is height-balanced or not.
A tree is height-balanced if the difference between the heights of left and right subtrees is not more than one for all nodes of the tree.
Example :
Input:
1
/
2
\
3
Output: 0
Explanation: The max difference in height of the left subtree and right subtree is 2, which is greater than 1. Hence unbalanced
Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/check-for-balanced-tree/1
Solution IDE Link: https://ide.geeksforgeeks.org/online-cpp-compiler/b4d0bdb1-df21-44e6-b8da-6f1ccc96a1d6
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK