| 115 | class Solution { |
| 116 | public: |
| 117 | void dfs(TreeNode* root, int val, int depth,int k){ |
| 118 | if(!root)return; |
| 119 | if(depth==k+1){ |
| 120 | TreeNode *templ=new TreeNode(val); |
| 121 | TreeNode *l=root->left; |
| 122 | root->left=templ; |
| 123 | templ->left=l; |
| 124 | TreeNode *tempr=new TreeNode(val); |
| 125 | TreeNode *r=root->right; |
| 126 | root->right=tempr; |
| 127 | tempr->right=r; |
| 128 | } |
| 129 | dfs(root->left,val,depth,k+1); |
| 130 | dfs(root->right,val,depth,k+1); |
| 131 | return; |
| 132 | } |
| 133 | TreeNode* addOneRow(TreeNode* root, int val, int depth) { |
| 134 | if(depth==1){ |
| 135 | TreeNode *temp=new TreeNode(val); |