当前位置:网站首页>[leetcode refers to offer 27. Image of binary tree (simple)]
[leetcode refers to offer 27. Image of binary tree (simple)]
2022-04-23 21:02:00 【Minaldo7】
subject :
source : Power button (LeetCode)
link :https://leetcode-cn.com/problems/er-cha-shu-de-jing-xiang-lcof
Copyright belongs to the network . For commercial reprint, please contact the official authority , Non-commercial reprint please indicate the source .
The problem solving process :
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */
class Solution {
public TreeNode mirrorTree(TreeNode root) {
if(root == null) return root;
TreeNode temp = root.right ;
root.right = root.left;
root.left = temp ;
mirrorTree(root.left);
mirrorTree(root.right);
return root;
}
}
Execution results :
版权声明
本文为[Minaldo7]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/111/202204210544479652.html
边栏推荐
- 笔记本电脑卡顿怎么办?教你一键重装系统让电脑“复活”
- Factory mode
- Realrange, reduce, repeat and einops in einops package layers. Rearrange and reduce in torch. Processing methods of high-dimensional data
- Prim、Kruskal
- Assertionerror: invalid device ID and runtimeerror: CUDA error: invalid device ordinal
- UKFslam
- setInterval、setTimeout、requestAnimationFrame
- wait、waitpid
- Pytorch selects the first k maximum (minimum) values and their indexes in the data
- Mysql database common sense storage engine
猜你喜欢
Question brushing plan - depth first search DFS (I)
C, print the source program of beautiful bell triangle
The more you use the computer, the slower it will be? Recovery method of file accidental deletion
2.整理华子面经--2
Thinkphp5 + data large screen display effect
Addition, deletion, modification and query of MySQL advanced table
Minecraft 1.12.2模组开发(四十三) 自定义盾牌(Shield)
MySQL数据库常识之储存引擎
Question brushing plan - depth first search (II)
Express ③ (use express to write interface and cross domain related issues)
随机推荐
小米手机全球已舍弃“MI”品牌,全面改用“xiaomi”全称品牌
Go限制深度遍历目录下文件
go slice
UKFslam
setInterval、setTimeout、requestAnimationFrame
On IRP from the perspective of source code
C, print the source program of beautiful bell triangle
Ubutnu20 installer centernet
Gsi-ecm digital platform for engineering construction management
笔记本电脑卡顿怎么办?教你一键重装系统让电脑“复活”
1. Finishing huazi Mianjing -- 1
Centralized record of experimental problems
Norm normalization in tensorflow and pytorch of records
Tencent cloud has two sides in an hour, which is almost as terrible as one side..
Detailed explanation of basic assembly instructions of x86 architecture
又一款数据分析神器:Polars 真的很强大
Recommended usage scenarios and production tools for common 60 types of charts
What about laptop Caton? Teach you to reinstall the system with one click to "revive" the computer
Prim、Kruskal