Python || Recursion || Easy 94 %beat
First we check root is None or not ,\nThen we will check depth/height of tree at each node , compare height left and right is less or more than 2.\n\n\n# Code\n
First we check root is None or not ,\nThen we will check depth/height of tree at each node , compare height left and right is less or more than 2.\n\n\n# Code\n```\n# Definition for a binary tree node.\n# class TreeNode:\n#     def __init__(self, val=0, left=None, right=None):\n#         self.val = val\n#         self.left = left\n#         self.right = right\nclass Solution:\n    def isBalanced(self, root: Optional[TreeNode]) -> bool:\n        if root is None:\n          return True\n\n        # This function will return height/ depth of tree\n        def depth(root):\n          if root is None:\n            return 0\n          return max(depth(root.left), depth(root.right)) + 1\n\n        l = depth(root.left)\n        r = depth(root.right)\n\n        return (abs(l-r) < 2) and self.isBalanced(root.left) and self.isBalanced(root.right)\n\n```\n\n**Plz Upvote ..if you got help from this.**\n\n.
['Tree', 'Recursion', 'Binary Tree', 'Python', 'Python3']