#110

Balanced Binary Tree

pupil · 390 · lc easy +24 · verified · 57.9% accepted · 12,141 likes · top 54%

play →

Description

Given a binary tree, return whether it is height-balanced — meaning the heights of the left and right subtrees of every node differ by at most one.

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

Example 3:

Input: root = []
Output: true

Code

1
2
3
4
5
6
7
8
9