2
#- * - coding : utf - 8 - * -3
#Definition for a binary tree node.5
#def __init__(self, val = 0, left = None, right = None):13
Solve(self, root, val, depth, curr, )14
: if root == None : return None if depth == 1 : return TreeNode(val, root) if curr15
== depth - 1 : (left, right) =16
(root.left, root.right)(root.left, root.right) =18
TreeNode(val, None, right)) return root self.Solve(root.left, val, depth, curr + 1) self19
.Solve(root.right, val, depth, curr + 1) return root21
def addOneRow(self, root, val, depth, )22
: return self.Solve(root, val, depth, 1)