Horje
check if binary tree is balanced python Code Example
check if binary tree is balanced python
def isBalanced(self, root: Optional[TreeNode]) -> bool:
        def depth(root):
            if not root:
                return 0
            return max(depth(root.left), depth(root.right)) + 1
        def solution(root):
            if not root:
                return True
            if abs(depth(root.left) - depth(root.right)) > 1:
                return False
            return solution(root.left) and solution(root.right)
        return solution(root)




Python

Related
fetch member by id discord.py Code Example fetch member by id discord.py Code Example
openign in browser python Code Example openign in browser python Code Example
plt Code Example plt Code Example
python print not working Code Example python print not working Code Example
telethon says telethon.errors.common.MultiError: ([FloodWaitError('A wait of 27 seconds is required (caused by GetParticipantsRequest)'), None, None, FloodWaitError('A wait of 27 seconds ) Co telethon says telethon.errors.common.MultiError: ([FloodWaitError('A wait of 27 seconds is required (caused by GetParticipantsRequest)'), None, None, FloodWaitError('A wait of 27 seconds ) Co

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7