当前位置:网站首页>[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
边栏推荐
- 使用mbean 自动执行heap dump
- [SDU chart team - core] enumeration of SVG attribute class design
- Pytorch selects the first k maximum (minimum) values and their indexes in the data
- go map
- Tensorflow1. X and 2 How does x read those parameters saved in CKPT
- Flomo software recommendation
- Common problems in deploying projects with laravel and composer for PHP
- go array
- Addition, deletion, modification and query of MySQL advanced table
- 笔记本电脑卡顿怎么办?教你一键重装系统让电脑“复活”
猜你喜欢

On IRP from the perspective of source code

中创存储|想要一个好用的分布式存储云盘,到底该怎么选

GSI-ECM工程建设管理数字化平台

Question brushing plan -- backtracking method (I)

Addition, deletion, modification and query of MySQL advanced table

Problem brushing plan -- dynamic programming (III)

go defer

Addition, deletion, modification and query of advanced MySQL data (DML)

2.整理华子面经--2

Deep analysis of C language pointer (Part I)
随机推荐
41. 缺失的第一个正数
Factory mode
Fastdfs思维导图
【SDU Chart Team - Core】SVG属性类设计之枚举
unity 功能扩展
MySQL advanced common functions
又一款数据分析神器:Polars 真的很强大
Reentrant function
[SQL] string series 2: split a string into multiple lines according to specific characters
Bracket matching -- [implementation of one-dimensional array]
Question brushing plan -- backtracking method (I)
Presto on spark supports 3.1.3 records
小米手机全球已舍弃“MI”品牌,全面改用“xiaomi”全称品牌
浅谈数据库设计之三大范式
危机即机遇,远程办公效率为何会提升?
常用60类图表使用场景、制作工具推荐
Deno 1.13.2 发布
Fastdfs mind map
Common commands of MySQL in Linux
Zhongchuang storage | how to choose a useful distributed storage cloud disk