Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training

117. Balanced Binary Tree

EasyDay 35 of 60Trees & BST

Given the root of a binary tree, return true if it is height balanced: at every node, the heights of the left and right subtrees differ by at most 1.

Example 1
Input: root = [3,9,20,null,null,15,7]
Output: true
Example 2
Input: root = [1,2,2,3,3,null,null,4,4]
Output: false
At the root, the left subtree has height 3 and the right subtree has height 1.
Constraints
  • The number of nodes is in the range 0 to 5000
  • -10^4 <= Node.val <= 10^4
Hints
Frequently asked at: Amazon, Google, Bloomberg
Ctrl + Enter runs the examples

Not sure what to learn next?

A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

  1. 1Discuss your goals
  2. 2Get a personal plan
  3. 3Start learning
Book for β‚Ή200/ 30 min