leetle
38. Balanced Binary Tree
Write a function solve that checks if a binary tree is height-balanced. 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: Input: [3,9,20,None,None,15,7] Output: True
Make sure you return your solution, don't print!
Python3
def solve(root):
pass
Binary Tree Definition
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right