当前位置:网站首页>[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
边栏推荐
猜你喜欢
wait、waitpid
Problem brushing plan -- dynamic programming (IV)
Chrome 94 引入具有争议的 Idle Detection API,苹果和Mozilla反对
flomo软件推荐
On IRP from the perspective of source code
1. Finishing huazi Mianjing -- 1
Gsi-ecm digital platform for engineering construction management
go defer
Lunch on the 23rd day at home
2.整理华子面经--2
随机推荐
MySQL进阶之数据的增删改查(DML)
Leetcode-279-complete square number
[SDU chart team - core] enumeration of SVG attribute class design
UKFslam
Solve importerror: cannot import name 'imread' from 'SciPy misc‘
Graph traversal - BFS, DFS
GSI-ECM工程建设管理数字化平台
Minecraft 1.12.2模组开发(四十三) 自定义盾牌(Shield)
IOT 设计与开发
go reflect
Is qiniu school useful and is the recommended securities account safe
Ubutnu20 installer centernet
Question brushing plan - depth first search (II)
1. Finishing huazi Mianjing -- 1
Flomo software recommendation
Problem brushing plan -- dynamic programming (IV)
MySQL基础合集
常用60类图表使用场景、制作工具推荐
Queue template code
MySQL进阶之表的增删改查