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.
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.
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.
Input: root = []
Output: true
Explanation:
An empty tree is considered balanced.
Accepted:
Submission: