Description:
So, we should change the right value of the root to the left value of the root.
Solution:
First, we have a condition: if the tree is empty, we just return root. I made the variable name "left", "right" which is pointer the right and the left value of the root.
We change the value of right to the left, the left to the right through recurrsion.
Finally, return the root.
'LeetCode ๐๏ธ > Tree' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
572. Subtree of Another Tree (0) | 2023.04.02 |
---|---|
102. Binary Tree Level Order Traversal (0) | 2023.03.21 |
124. Binary Tree Maximum Path (0) | 2023.03.20 |
100. Same Tree (1) | 2023.02.21 |
104. Maximum Depth of Binary Tree (0) | 2023.02.20 |