0110. Balanced Binary Tree

https://leetcode.com/problems/balanced-binary-tree

Description

Given a binary tree, determine if it is height-balanced.

For this problem, a height-balanced binary tree is defined as:

a binary tree in which the left and right subtrees of every node differ in height by no more than 1.

Example 1:

Example 2:

Example 3:

Constraints:

  • The number of nodes in the tree is in the range [0, 5000].

  • -104 <= Node.val <= 104

ac

O(n), traversal is always O(n)

Last updated

Was this helpful?