✅Python3 🔥easiest solution 53ms🔥🔥
Intuition\n Describe your first thoughts on how to solve this problem. \nUsing DFS we can solve this.\n# Approach\n Describe your approach to solving the proble
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUsing DFS we can solve this.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- first check if node is None then return 0, because None node is balanced.\n- if not then get count of left or right subtree.\n- now if abs(right - left) > 1 then it\'s not balanced tree, then return -1\n- if any of left or right height is -1 then we already found imbance in tree, so return -1.\n- now else all of above cases return 1 + max(left, right), because indicating maxdepth till now no matter left or right.\n- now if returned answer is > 0 then return true else false.\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def isBalanced(self, root: Optional[TreeNode]) -> bool:\n        R = root\n        def helper(curr=root):\n            if curr == None:\n                return 0\n            else:\n                left = helper(curr.left)\n                right = helper(curr.right)\n                if left == -1 or right == -1:\n                    return -1\n                elif abs(right - left) > 1:\n                    return -1\n                return 1 + max(left, right)\n        return helper() >= 0\n```\n# Please like and comment below :-)
['Tree', 'Depth-First Search', 'Binary Tree', 'Python3']