• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
October 11, 2023 |1.8K Views
PROBLEM OF THE DAY: 10/10/2023 | Nodes at given distance in binary tree
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Siddharth Hazra. 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/29aa15cf-467d-46d8-bfd7-0e9ce97c0d14