Python beats 99% (40ms)
\nclass Solution:\n    def depth(self, root: TreeNode) -> int:\n        if not root:\n            return 0\n        hl = self.depth(root.left) + 1\n        hr =
```\nclass Solution:\n    def depth(self, root: TreeNode) -> int:\n        if not root:\n            return 0\n        hl = self.depth(root.left) + 1\n        hr = self.depth(root.right) + 1\n        if abs(hl - hr) > 1:\n            raise Exception("Sorry, the tree is unbalanced")\n        else:\n            return max(hl, hr)\n        \n    def isBalanced(self, root: TreeNode) -> bool:\n        try:\n            self.depth(root)\n        except:\n            return False\n        return True\n```\nabout try and excpet: https://www.w3schools.com/python/python_try_except.asp
['Python', 'Python3']