# warn: a node just have a child, a node have two child, their height calculation method are different. if left_depth > 0and right_depth > 0: returnmax(left_depth, right_depth) + 1; elif left_depth > 0: return left_depth + 1 else: # right_depth > 0, or (left_depth == 0 and right_depth == 0) return right_depth + 1
# @param root, a tree node # @return an integer defmaxDepth(self, root): returnself.recurMaxDepth(root, 0)