Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Balanced Binary Tree

XPChallenge Points: 10
levelLevel: Easy

A balanced binary tree is a tree where the height of the left and right subtrees of every node differs by at most 1.

Return true if the tree is balanced, otherwise return false.

Example 1:

Input: root = [10,5,15,2,7,12,20]

Output: true

Explanation:

Every node’s left and right subtree heights differ by no more than 1.

Example 2:

Input: root = [1,2,2,3,null,null,3,4,null,null,4]

Output: false

Explanation:

Some nodes have left and right subtree heights differing by more than 1.

Example 3:

Input: root = []

Output: true

Explanation:

An empty tree is considered balanced.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result