Sorry, I really forgot what's happening 5 months ago...

Just remember that I cannot pass by DFS, then I use BFS pass the problem, slowly so I redo this problem today.

Is that Online Judge got memory improved? The code as below:

```
# @param root, a tree node
# @return a boolean
def isBalanced(self, root):
def CalcTreeDepth(root):
if root == None:
return 0, True
left_depth = 0
right_depth = 0
result = True
if root.left != None:
left_depth, result = CalcTreeDepth(root.left)
if result == False:
return 0, False
if root.right != None:
right_depth, result = CalcTreeDepth(root.right)
if result == False:
return 0, False
if abs(left_depth - right_depth) > 1:
return 0, False
root.depth = max(left_depth, right_depth) + 1
return root.depth, True
dep, result = CalcTreeDepth(root)
return result
```