当前位置:网站首页>JZ27 二叉树的镜像
JZ27 二叉树的镜像
2022-07-20 21:38:00 【syc596】
JZ27 二叉树的镜像
二叉树的镜像_牛客题霸_牛客网 (nowcoder.com)
//1
//自顶向下
import java.util.*;
public class Solution {
public TreeNode Mirror (TreeNode root) {
if(root==null){
return null;
}
TreeNode tmp=root.left;
root.left=root.right;
root.right=tmp;
Mirror(root.left);
Mirror(root.right);
return root;
}
}
// //自底向上
// import java.util.*;
// public class Solution {
// public TreeNode Mirror (TreeNode root) {
// if(root==null){
// return null;
// }
// Mirror(root.left);
// Mirror(root.right);
// TreeNode tmp=root.left;
// root.left=root.right;
// root.right=tmp;
// return root;
// }
// }
边栏推荐
- Mohist patrol source code
- 每日一题-LeetCode1260-二维网格迁移-数组-映射
- [hardware foundation 4] diode (principle, characteristics, type, circuit analysis)
- L'ipaylinks, un service d'intégration des paiements transfrontaliers, a remporté le prix 3A Asia de l'actif!
- IIO device driver of I2C client driver
- PHP cross domain solution
- I2C client Drive
- How to make localstorage support expiration time setting?
- Zhaocai meow | jade meow, brother Tai pours ten thousand Liang, a pear flower, a summer rain
- The middle-aged crisis in the Internet industry is the watershed of 35 years old
猜你喜欢
Dama Chapter 4 (data architecture)
Blueprism tool menu bar user rights function description -rpa Chapter 2
Source code, complement and fixed-point number operation
Difference between service and systemctl / method of modifying path / a command to view IP address, gateway and DNS server
conda虚拟环境默认路径如何修改
[hardware foundation 4] diode (principle, characteristics, type, circuit analysis)
Project summary: document management system
Three structures of C language
ORA-1142 signalled during: ALTER DATABASE END BACKUP...
In the future, a new way of tourism, VR traveling without leaving home, embracing poetry and distance
随机推荐
Which is the best multilingual mall system? Comparison of three famous cross-border e-commerce manufacturers
How can do while call the ODPs SQL written?
[shutter -- actual combat] quick start shutter
[JS] dynamic rendering page
设置 当前样式dimstyle
專注跨境支付一體化服務 iPayLinks榮獲《財資》(The Asset)3A亞洲獎!
Le moteur 3D de dtos titos remplacera le moteur de jeu Giant Beast et réalisera la substitution de localisation
Dama summary (summary of data management)
Dama Chapter 4 (data architecture)
Is there any risk in opening a mobile stock account? Is it safe?
Dama Chapter 12 (metadata management)
Pilote d'adaptateur I2C
I2C client Drive
Daily question-leetcode1260-2d grid migration array mapping
Bank data management measures
i2c client驅動
i2c client驅動之IIO設備驅動
Wechat vaccine reservation applet graduation design of applet completion work (3) background function
Easygbs platform setup tips: how to hide the platform web page from being accessed?
Dama Chapter 7 (data security)